-
All replies
-
Helpful answers
-
Apr 1, 2014 4:07 PM in response to Tony T1by bj49wd,Interesting... the original spreadsheet did come from an external source, most likely Excel and then was delivered to me via Google Docs... and then I messed with it in Numbers... I wonder if there's a "Show Invisible Characters" feature in Numbers...?
Thanks again!
-
May 4, 2014 1:04 PM in response to Tony T1by kmgold,Hi, Sorry to add to this thread, but I'm strapped for time and I need assistance with the scripts described here; I am not able to get any of them to work. My situation is almost identical: The images are in a folder called "images" on my desktop (~/Desktop/images) and the csv file is contained within it (~/Desktop/images/SND.csv)
So, for example in line 1:I would like the file named 0031.jpg to be changed to 31-Dallas Morning News.jpg. I've been at this problem for a while, so any assistance would be greatly appreciate it.
-
May 4, 2014 1:24 PM in response to kmgoldby Tony T1,The 1st bash script listed here should work:
#!/bin/bash
cd ~/Documents/images
while read line
do
OldImageName=${line%,*}
NewImageName=${line#*,}
mv "$OldImageName" "$NewImageName"
done <"SND.csv"
As is does not, try this, then post a few lines of the error.txt file that will be created on the Desktop
#!/bin/bash cd ~/Documents/images while read line do OldImageName=${line%,*} NewImageName=${line#*,} echo mv "$OldImageName" "$NewImageName" >> ~/Desktop/error.txt done <"SND.csv" -
May 4, 2014 4:23 PM in response to Tony T1by kmgold,Thanks for the prompt reply.
Originally, when running the script, there was no error, but there was no affect on any of the images.
On a second try, I omitted the first line cd ~/[Desktop]/images and tried saving the script in the folder with everything else and running it from there. At that point, I get a "while: bad interpreter: No such file or directory" error message in the terminal.
Nothing shows on the desktop at either point.
Perhaps I am executing the script incorrectly?
I used SublimeText to create a new script, which i called "rename.sh." I then navigated to it's directory, changed the permissions using the following command: "chmod +x ./rename.sh." I then ran it using the "./rename.sh" command.
Let me know if you need further details and thanks again.
-
May 4, 2014 5:23 PM in response to kmgoldby Tony T1,Make sure that the 1st line in the script is:
#!/bin/bash
If it still doen not work, try using TextEdit and save as a Plain Text File
(TextEdit->Format->Make Plan Text)
If it still does not work, in Terminal, what do you get when you run: which bash
-
May 5, 2014 8:29 AM in response to Tony T1by kmgold,Still not working; when I run the script from the desktop directory, I get no errors and no affect on the images in the folder.
When the script is run from the images directory, I get the following, based on whether or not I include the first (second after #!/bin/bash) line.
cd: bad interpreter: No such file or directory
-or-
while: bad interpreter: No such file or directory
which bash yields "/bin/bash"
-
May 5, 2014 8:47 AM in response to kmgoldby Tony T1,Try to run from Applescript.
Copy this to Apple Script Editor, and click [Run]
Also click [Result] at the bottom of AppleScript Editor to show any errors:
do shell script " cd ~/Desktop/images while read line do OldImageName=${line%,*} NewImageName=${line#*,} mv \"$OldImageName\" \"$NewImageName\" done < \"SND.csv\" " -
May 5, 2014 9:01 AM in response to Tony T1by kmgold,""
The above is what shows in "Result" when run as an AppleScript - still no effects on the image files.
Could it be a permissions issue on the image files themselves? I have Read & Write access to each image but "Everyone" and "staff" has Read only permission.
-
May 5, 2014 9:17 AM in response to kmgoldby Tony T1,Try this in AppleScript, and post the first few lines of what's created in the file error.txt on the desktop:
do shell script "
cd ~/Desktop/images
while read line
do
OldImageName=${line%,*}
NewImageName=${line#*,}
echo mv \"$OldImageName\" \"$NewImageName\" >> ~/Desktop/error.txt
done < \"SND.csv\"
" -
May 21, 2014 1:20 PM in response to Tony T1by Amosiko,Hi Tony,
I have tried the Automater but for whatever reason I can't get it to work. It says the workflow is complete and nothing changes with file name for the images does not change.
-
May 21, 2014 1:39 PM in response to Amosikoby Tony T1,Are you sure your CSV file is the same format as the OP?
Post a screenshot of your CSV file.
-
-
May 21, 2014 1:44 PM in response to Amosikoby Amosiko,This is the Run Shell Script I am using:
cd "$1"
while read line
do
OldImageName=${line%,*}
NewImageName=${line#*,}
if [ -e "$OldImageName" ] ; then
mv "$OldImageName" "$NewImageName"
else
echo "$OldImageName" >> ~/Desktop/Errors.txt
fi
done <"$2"
-
May 21, 2014 1:48 PM in response to Amosikoby Tony T1,Are you getting an Error.txt file on the Desktop?
-
May 21, 2014 1:49 PM in response to Tony T1by Amosiko,I am but it comes across as jiberish unforntantly.



