Hey, a newbie here :)
I want to write a script which helps me to rename my photos directly after i put them from my sd card on my computer.
For example: the original names of my files are: "FT200365.RAF", "FT200366.RAF", "FT200367.RAF".
Now i want them to be named like this: xx-YYYY-MM-DD-0001-a1b2c3d4.raf"
"xx" = custom credentials
"YYYY-MM-DD"= shooting date
"0001"= sequence which follows the original sequence of the files in the folder so that they are not mixed and for example FT200367 turns out to be 0001.
"a1b2c3d4"= a random generated sequence of numbers and lowercase letters that always alternate, so that no number is directly followed by another number.
I want to save the script into a file, then copy it to the terminal which i start in the specific folder where the batching progress should begin. so that i don't need to assign a specific location. the complete name including the filetype should be in lowercase letters. also i want to include the original filename in the medata or a seperate xmp file like in adobe bridge
The original files should not be overwritten and the renamed files should be placed next to the orignal so it should look like this:
ak-2024-02-29-0001-k7f9c3m1.raf
ak-2024-02-29-0002-l8v4n5z2.raf
ak-2024-02-29-0003-p2j9c1x7.raf
FT200365.RAF
FT200366.RAF
FT200367.RAF
I know this is a very specific question and maybe i should use a GUI-tool but i can't find a reliable one for fedora39 which seems to work for exactly that process.
Thank you for your help and thoughts!
Since you mention fedora and need case sensitivity, I'm assuming you're on a Linux system.
Do you want the files to be renamed or do you want to make a copy with a new name. It isn't quite clear as you say you want them renamed, but then say you want to keep the original files, which wouldn't be a renaming operation.
Yeah, i'm mainly on linux.
by "keeping the original files" i meant that i want to have a backup. exiftool seems to create a copy called "image.jpg_original" when performing an action. i want that but i dont care if the copy gets overwritten or the original-original file. if it doesnt work i have to create a copy myself which of course isnt a problem, but i thought i mention it anyway
Quote from: nrp31585 on February 29, 2024, 01:01:50 PMexiftool seems to create a copy called "image.jpg_original" when performing an action.
My copy/paste on this
From the docs (https://exiftool.org/exiftool_pod.html#DESCRIPTION)
By default the original files are preserved with _original appended to their names -- be sure to verify that the new files are OK before erasing the originals.
You can suppress the backup files with the
-overwrite_original option (https://exiftool.org/exiftool_pod.html#overwrite_original). You can tell exiftool to delete them afterwards with the
-delete_original option (https://exiftool.org/exiftool_pod.html#delete_original).
Now, that said, exiftool doesn't create a backup copy when only renaming the file, only when actually editing embedded data. So in order to keep the original and a new renamed copy, the
-o (
-out) option (https://exiftool.org/exiftool_pod.html#o-OUTFILE-or-FMT--out) will need to be used.
One thing you might think about would be saving the original name into the file in case you want to fully reverse the rename. The appropriate place would be the
PreservedFileName and/or
Title tags.
First, try this command and see if the output will have the correct names
exiftool -d '%Y-%m-%d' '-TestName<ak-${DateTimeOriginal}-%-.4nC-${Now;my @chars=("a".."z");$_=join ""=>map $chars[rand @chars].int(rand(10)),1 .. 4;}.%le' *.RAFIf the output is correct, then I think this would create new copies while leaving the old files alone. Test it first.
exiftool -d '%Y-%m-%d' -o . '-FileName<ak-${DateTimeOriginal}-%-.4nC-${Now;my @chars=("a".."z");$_=join ""=>map $chars[rand @chars].int(rand(10)),1 .. 4;}.%le' *.RAFThe
Now tag normally would return the current date/time. It's being used as a placeholder in order to process the random letter/number code because it always exists and
Now is shorter than some other tags that always exist such as
Filename.
Some caveats. This is depending on
*.RAF being case sensitive when looking at files, i.e. it will give a list of .RAF files and not .raf files. I don't use linux, so I'm not sure.
Windows is a case-insensitive file system, so it's probably not possible to process only .RAF and not .raf. At least, I can't think of a way.
You cannot use the
-r (
-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) with this command because of the wildcard. See that link and Common Mistake #2 (https://exiftool.org/mistakes.html#M2).
If the filesystem preserves case but isn't case sensitive, you could do this to process only capital RAF files:
exiftool -ext raf -if '$filename =~ /\.RAF$$/' ...
- Phil
Bah, silly me. That was the obvious answer and I've used it before. My mind was stuck on the -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension).