File rename inconsistencies upon move

Started by murphysm2342, March 21, 2017, 02:01:07 PM

Previous topic - Next topic

murphysm2342

Hello,
I'm having a strange issue with a script I've made.  It is placed within an Automator application and runs when files are dragged onto the application.

WHAT THE SCRIPT DOES:
1. moves drag/dropped files to a specified server
2. reads the filename and creates new directories if they do not exist (1. first letter of filename, 2. first five characters of filename, 3. first ten characters of filename, 4. first fifteen characters of filename)
3. modifies filename and gives the file a new sequential number if file with same name already exists.

ISSUE THAT I'M SEEING:
The file renaming works differently when the files are originally located on the user's local machine versus if they are located on the same fileserver as the destination folders.

EXPECTED FILENAME RESULT:
colorcard123456_01.JPG
colorcard123456_02.JPG
colorcard123456_03.JPG
The above is the result that we are seeing with local files that are run through the application and moved/renamed to the file serve.

ACTUAL RESULT FOR FILES FROM FILESHARE: Below is the result we are seeing with files already located in a different part of the same file serve:
colorcard123456_011.JPG
colorcard123456_021.JPG
colorcard123456_031.JPG

What might be causing this difference?  Input files are exactly the same just coming from different locations.

CODE - here is the exiftool code that is doing the work:
exiftool -o . -directory="Volumes/extensis/product/%1f/%5f/%10f/%15f -FileName=%15f%+.2nc.%e filePath

Full application script with code in context if that helps:

on run {input}
set exiftool_path to "/usr/local/bin/"
set alphaDirectoryPath to "Volumes:extensis:product:"
set alphaDirectoryPathPOSIX to POSIX path of alphaDirectoryPath
repeat with eachFile in input
set thePath to POSIX path of eachFile
set fileName to input as text
set string1 to "_p" as text
set string2 to "_m" as text
set string3 to ".psd" as text
set string4 to ".mov" as text
if fileName contains string1 then
do shell script exiftool_path & "exiftool -o . -directory=" & quoted form of alphaDirectoryPathPOSIX & "/%1f/%5f/%10f/%15f -FileName=%19f%.1nc.%e " & quoted form of thePath
else if fileName contains string2 then
do shell script exiftool_path & "exiftool -o . -directory=" & quoted form of alphaDirectoryPathPOSIX & "/%1f/%5f/%10f/%15f -FileName=%19f%.1nc.%e " & quoted form of thePath
else if fileName contains string3 then
do shell script exiftool_path & "exiftool -o . -directory=" & quoted form of alphaDirectoryPathPOSIX & "/%1f/%5f/%10f/%15f -FileName=%15f%+.2nc.%e " & quoted form of thePath
else if fileName contains string4 then
do shell script exiftool_path & "exiftool -o . -directory=" & quoted form of alphaDirectoryPathPOSIX & "/%1f/%5f/%10f/%15f -FileName=%15f%+.2nc.%e " & quoted form of thePath
else
do shell script exiftool_path & "exiftool -o . -directory=" & quoted form of alphaDirectoryPathPOSIX & "/%1f/%5f/%10f/%15f -FileName=%15f%+.2nc.%e " & quoted form of thePath
end if
end repeat
end run

Phil Harvey

It looks like somehow an extra "1" is getting added to the file name.  Are you absolutely sure your script didn't have "%+.2nc1.%e" accidentally?  I'm assuming not, but I had to ask.

Otherwise, diagnosing this problem will be difficult.  If you could reproduce the problem with a simple sequence of commands in the Terminal then it could help.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

murphysm2342

yeah, positive it didn't have "%+.2nc1.%e" accidentally.  Copy/pasted from the app just after running it.  And previously had tried messing with that part but got even stranger results.  Will try troubleshooting via Terminal.  Thanks.