is it posable to use a find and combidine it will renaming file?
I don't understand the question.
I am looking to combine exiftool with find "filepath -iname "*_s*" ; && find "filepath -iname "*_f*" ; rename file that have _s one filenmae and file that have -f in them another filename.
The OS I am using is OSX 10.15 and the lastest version of exiftools I am also working with .tif files
I'd suggest redirecting the output from find into a temp file. Hopefully, find is just giving the a list of the file paths. You can then use the -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE) to pass the list to exiftool.
Basically, something like this if you were removing the _s part
exiftool "-Filename<${Filename;s/_s//}" -@ OutputFromFind.txt
I am waniting to do this if filename contains or is then change file name
would this work
exiftool -r -if '$Filename=~/_s\.tif/i' - FileName<${CreateDate;DateFmt("%Y%m%d")}_fadgi19264_$TargetNum_${CreateTime;DateFmt("%H%M")}_Start%.2nc.%e/"
You need quotes around the second half due to the < sign. You only have a double quote at the very end and double quotes around the whole thing will make the terminal treat all dollar signs as shell variables instead of exiftool tags. And I don't recall any tag called "TargetNum" so I don't know what you're doing there.
But otherwise, the syntax is correct.
When running this how do I know it is going to run on a protocolar dir and file?
Quote from: j99mac on October 29, 2021, 08:37:44 AM
I am wanting to do this if filename contains or is then change file name
would this work
exiftool -r -if '$Filename=~/_s\.tif/i' - FileName<${CreateDate;DateFmt("%Y%m%d")}_fadgi19264_$TargetNum_${CreateTime;DateFmt("%H%M")}_Start%.2nc.%e/"
You must specify the directory on the command line.
- Phil
When I run this command with a full link path at the end it works. But if the path is a variable then it does not work.
exiftool '-FileName<${CreateDate;DateFmt("%Y%m%d")}_target_'$tNum'_${DateTimeCreated;DateFmt("%H%M")}_finsh_'$type1'.%e $path
I would also like it to run base on the the filename is. Example if filename is abc_target_finsh then name the file with _finsh at the end
Do I need to put the the variable in quotes "$path" at the end of the script?
Also if there are multiple folders
example
abc/test
abc_test_finsh
abcd/test
abcd_test_finsh
How can how can I get the script to run recursively on files in subdir
I am running the following command to rename files. When I run exiftool -r it only rename one of the sub directories. Is there another way to run exiftool to rename files recursively?
echo "Enter the file path"
read path
cd $path
find $path -iname "*target*" ;
exiftool -r '-FileName<${CreateDate;DateFmt("%Y%m%d")}_test_${CreateDate;DateFmt("%H%M")}_start.%e' **/*_start.tif
exiftool -r '-FileName<${CreateDate;DateFmt("%Y%m%d")}_test_${CreateDate;DateFmt("%H%M")}_finsh.%e' **/*_finsh.tif
exit 0
Quote from: j99mac on December 07, 2021, 01:35:26 PMIs there another way to run exiftool to rename files recursively?
You can't use wildcards and recurse. See the
-r (
-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) and Common Mistake #2c (https://exiftool.org/mistakes.html#M2).
You'll have to filter using the
-if option (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR) and RegEx. For example
-if '$Filename=~/_finsh.tif/'
Do you put the if option before the command.
exiftool -r -if '$Filename=~/_s\.tif/i' - FileName<${CreateDate;DateFmt("%Y%m%d")}_fadgi19264_$tNum_${CreateTime;DateFmt("%H%M")}_Start%.2nc.%e/"
As with nearly all exiftool options, it can appear anywhere in the command. At the beginning, middle, or end, as long as it doesn't split a two part option such as the-TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT) or the -p (-printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat).
I did some testing
with exiftool -r -if '$Filename=~/_s\.tif/i' '-FileName<FileModifyDate' -d %Y%m%d_#_%H%M_s.%%e
and get failed conditions
Do I need to add "" around '$Filename=~/_s\.tif/i' '-FileName<FileModifyDate' -d %Y%m%d_#_%H%M_s.%%e. ?
The command syntax looks good if you are on Mac.
Can you paste your exact command and the output for a single file that you think should pass the condition?
- Phil
What if I want to run the command on multiple file in multiple folders named test
You should get it working on one file first.
Learn to walk before you run.
- Phil
What if i want to run it on multiple directories and have it run on all finel with _s in files names. Would it work?
If it works on one file, it will work on many.
is it posable to run the command on a bunch of directories at once?
Please read at least the first paragraph of the application documentation (https://exiftool.org/exiftool_pod.html#DESCRIPTION).
Quote from: j99mac on December 08, 2021, 11:50:38 AMDo I need to add ""
On a Mac, you want single quotes
' around any parameter that contains a dollar sign
$. See the text at the bottom of Phil's post.
This is my command
exiftool -r -if '$Filename=~/_start\.tif/i' "-FileName<FileModifyDate" -d "%Y%m%d_fadgi19264_Model01_%H%M_start_g.%%e" (dir)
I ran it and now is there away to make "%Y%m%d" be the CreateDate? I am looking to get the created ate field in my filename.
I used this at one point {CreateDate;DateFmt("%Y%m%d")} and it worked with a single file.
CreateDate or FileCreateDate?
Also, you need a time component (HourMinuteSecond) in addition to YearMonthDay. And where are you copying the time stamp from?
You really need to give more information in your posts and show what you've tried. There's a limit to how helpful and patient I am when I have to keep asking question trying to figure out what you're doing.
Search the forums by using this Google link (https://www.google.com/search?q=site:exiftool.org). Take time to read the documentation and FAQs.