I want to use exiftool to change the names of my files in one directory to the creation time (I'm on Windows 10).
I "installed" exiftool under C:\Windows as recommended.
I also set the path for exiftool.
I created a directory under the path C:\testordner where I copied all
my files into.
I opened the commandline in windows.
When I enter the command: C:\testordner>exiftool . everything works and i get the exif data of all files inside this directory.
When I enter the command: C:\testordner>exiftool IMG_0160.JPG it works too.
After reading the documentation I tried the following command to change the filenames of all my files in the directory to the creationdate:
C:\testordner>exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" .
When I try to run this command I always get the error message: "System cannot find the specified file" (In german: Das System kann die angegebene Datei nicht finden.)
I also tried:
C:\testordner>exiftool '-FileName<CreateDate' -d %Y-%m-%d_%H.%M.%S%%.%%le .
What do I do wrong? I don't get it.
From the exiftool main page, Running in Windows:
"Note that when typing commands in the "cmd.exe" shell, you should use double quotes instead of single quotes as shown in some examples"
Under Windows CMD, change the single quotes to double quotes and your command works correctly.
Related
I want to use Python to open a directory in a Win10 cmd window, and keep the window open.
I made a batch file named: open_dir_in_cmd_window.CMD:
CD /D %1
I tested that batch file successfully, by creating another batch file named, Test.cmd:
Rem "open_dir_in_cmd_window.CMD" "f:\backup"
"open_dir_in_cmd_window.CMD" "f:\backup"
A very helpful webpage provides the following example, which I seem unable to follow correctly:
Spaces in Program Path + parameters with spaces:
CMD /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
I made a python script, which contains the following lines, which alas, triggers an error message:
import subprocess
subprocess.run(cmd /k "E:\open_dir_in_cmd_window.CMD f:\backup")
When I open a Command Prompt window and run:
"C:\ProgramData\Anaconda3\python.exe" E:\open_dir.py
I get an error message, SyntaxError: invalid syntax, with this:
subprocess.run(cmd /k "E:\open_dir_in_cmd_window.CMD f:\backup")
^
I've tried many different permutations of double quoting and can't figure out the right way to do it.
I have spent many hours hunting on the web and trying to figure this out and I do not know what to do.
Any suggestions would be appreciated.
I recently try linux (from windows), and I find it difficult to process my following windows command to linux bash.
The windows command was:
set /p cutoff=Set BLAST E-Value Cutoff[1e-]:
for %%F in (*.fa) do program.exe -parameter1 %%F -parameter2_cutoff 1e-%cutoff% -output_file %%~dpnF.fas & type %%F %%~dpnF.fas > %%~dpnF.txt
This script takes a numeric value from user and uses it to run a program in every .fa files on a folder with the desired cutoff. Here %%~dpnF takes only the filename (without file extension). In this very script, I join the content of each input file (.fa) and its generated output (.fas) and finally merge them in final output (.txt). Here, for each Input file, there will be a final output file.
To run it in ubuntu , I try
echo "Set BLAST E-Value Cutoff[1e-]:"
read cutoff
for $f in *.fa; do program -parameter1 $f -parameter2_cutoff 1e-$cutoff -output_file $~dpnF.fas & cat $f $~dpnF.fas > $~dpnF.txt; done
Immediately it shows that linux is not supporting dpn type of command in windows and also the scripts terminates abruptly, showing no output.
Although I understand the different file extensions are not very meaningful in linux, but I have to keep it this way for other programs to process them.
I appreciate any type of help.
Thanks
The sequence %~dpn is used to get:
%~d - The drive
%~p - The path
%~n - The file name
Check the meaning of all expansions here.
The drive has no meaning in Linux. The path, full or partial, could be extracted with the command dirname and the filename could be extracted with the command basename.
The sequence %%~dpn means to get the whole pathname from root (/).
In fact, you do not need that in Linux, if a list of files was created with *.f, the list of files will be relative to the "present working directory" (command pwd), no need to extend them.
And to strip the extension from a filename, use ${f%.*}.
That cuts the string in "$f" at the last dot . and anything that follows *.
Then just add the extension you want: ${f%.*}.fas
Also, the character & has the meaning of "run the previous command in the background", which is not what you want.
And finally, the for $f should be replaced by for f.
This is a cleaner translation:
echo "Set BLAST E-Value Cutoff[1e-]:"
read cutoff
for f in *.fa; do
program -parameter1 "$f" \
-parameter2_cutoff "1e-$cutoff" \
-output_file "${f%.*}.fas"
cat "$f" "${f%.*}.fas" > "${f%.*}.txt"
done
I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.
How in Linux or MacOS X to rename a bunch of files with names 20141207_190822.jpg and 20141207_190823.mp4 to this format:
2014-12-07 19.08.22.jpg
and
2014-12-07 19.08.23.mp4
?
I've found many examples how to just add something to the beginning of filename, but here I need to change the mask by inserting symbols in the middle of filenames and replacing _ with space " ".
Thank you
Try doing this :
$ rename 's#^(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})#$1-$2-$3 $4.$5.$6#' *
There are other tools with the same name which may or may not be able to do this, so be careful.
If you run the following command :
$ file $(readlink -f $(type -p rename))
and you have a result like
.../rename: Perl script, ASCII text executable
then this seems to be the right tool =)
If you don't have this command, search your package manager to install it or do it manually
Last but not least, this tool was originally written by Larry Wall, the Perl's dad.
I'm using ImageMagick to do some image processing from the commandline, and would like to operate on a list of files as specified in foo.txt. From the instructions here: http://www.imagemagick.org/script/command-line-processing.php I see that I can use Filename References from a file prefixed with #. When I run something like:
montage #foo.txt output.jpg
everything works as expected, as long as foo.txt is in the current directory. However, when I try to access bar.txt in a different directory by running:
montage /some_directory/#bar.txt
output2.jpg
I get:
montage: unable to open image
/some_directory/#bar.txt: No such file
or directory # blob.c/OpenBlob/2480.
I believe the issue is my syntax, but I'm not sure what to change it to. Any help would be appreciated.
Quite an old entry but it seems relatively obvious that you need to put the # before the full path:
montage #/some_directory/bar.txt output2.jpg
As of ImageMagick 6.5.4-7 2014-02-10, paths are not supported with # syntax. The # file must be in the current directory and identified by name only.
I haven't tried directing IM to pull the list of files from a file, but I do specify multiple files on the command line like this:
gm -sOutputFile=dest.ext -f file1.ppm file2.ppm file3.ppm
Can you pull the contents of that file into a variable, and then let the shell expand that variable?