Hello everyone!
Im having a few problems with my file moving script.
Im trying to move files into folders based on the filenames and if a file already exists rename that file.
The files consists of three sets of different filenames. They will be moved/sorted into the folder structure below. The Source and Destination path will always be static.
The code below kind of works but there must be a better way to loop through the files than to use two �While do� statements.
Another thing I'm having trouble with is if a file already exists, I would like to rename or append something to that existing file. I tried with --backup but all I get is illegal option, most likely due to me testing this on MacOS.
My intension is to run this on my Synology server as an automated task every evening.
When i try to execute the script on the server it complains about the Source path, maybe not correctly formatted? find: `"/volume1/Archive/IMAGES/UPLOAD/TIFF/"': No such file or directory
Hmmm - I don't see /volume1/Archive/IMAGES/UPLOAD/DNG/ referenced anywhere in your script - that error msg can't come from that script. Does the DNG directory exist in the path?
Sorry, that was a typo. I used the DNG directory befor, but now only the TIFF and JPEG, still get the same error and they do exist.
--- Post updated at 14:24 ---
Thanks, i'm pretty new to this, not quite sure i get the hint.
so this would find all files with .jpg and .tif but only from one path. How can i search both SRC1 and SRC2. (find \"$SRC1\" -type f -iname '*.tif' -o -iname '*.jpg' -print0)
Great, thanks! now i don't get any errors, but also the script is not working. Nothing is happening, no error codes.
Obviously i must be missing something.
Again: too many escapes. Drop one of the two back slashes in the read delimiter's -d definition. Same for ALL the escaped double quotes around file and directory names downstream.
Sure your sophisticated regex to analyse $n works reliably? I'd prefer to determine the number length upfront, and then dissect $n .
You might want to provide a default valuein case $DST is undefined, to avoid creating directories in root.
Thanks so much for pointing that out, now it works beautifully
So far it has been reliable, but i will look into changing it your suggestion.
Thanks again!