-
All replies
-
Helpful answers
-
Dec 27, 2015 4:28 PM in response to Tony T1by userremoved,Hello again,
Sorry for keep having to get in touch, I've been spending hours on this, sometimes it works and other times I get errors. I run into errors everytime I switch files. I've got to resave all the images again because I forgot to add the .jpg suffix and they won't upload into Wordpress (stressful for a friday)
I've attached a picture, I can only select 'Storage' in Variable, if i click the dropdown and click New Variable it just makes a 'Storage 2'. Maybe it's not even that which is the issue.
I hand typed 'Choose CSVFile' in the Ask for Finder Items.
Thanks for you help
-
Jan 31, 2014 5:51 PM in response to userremovedby Tony T1,The variable name (Storage) is not the issue. Name does not matter, as we're not referencing it by name (we're using $1 and $2).
The problem appears to be that the line read is a file that does not exist (or an typo in the csv file).
Just need to add a line to test if the file exists.
So try with this:
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"
If there is an error, it will be listed in the file Errors.txt on the Desktop
-
Jan 31, 2014 6:26 PM in response to Tony T1by Tony T1,Opps!, forgot to quote if [ -e "$OldImageName" ]
Use:
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"
If there is an error, it will be listed in the file Errors.txt on the Desktop
-
Dec 27, 2015 4:28 PM in response to Tony T1by userremoved,Hey Tony,
Using the latest Script I got...
Error.txt
Old Image Name
-
Dec 27, 2015 4:28 PM in response to userremovedby userremoved,I saved out the CSV file again and readded the photos into the folder, a test of 5 images worked. I'll do all 1000+ tomorrow and see how it goes
-
Dec 27, 2015 4:28 PM in response to userremovedby userremoved,There is something that happens during the Automator that changes the .jpg file. They cannot be loaded into Wordpress I get an error message saying:
“Ditch_Witch_SK_300.jpg%0D” has failed to upload due to an error
Sorry, this file type is not permitted for security reasons.
-
Feb 1, 2014 8:32 AM in response to userremovedby Tony T1,kittersa wrote:
Hey Tony,
Using the latest Script I got...
Error.txt
Old Image Name
Good! That's the Header in your CSV FIle, so all other lines should have processed without error.
If you don't want the Error.txt file produced, just comment out the 2 lines with a # like so:
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"
-
Feb 1, 2014 9:04 AM in response to userremovedby Mark Jalbert,“Ditch_Witch_SK_300.jpg%0D” has failed to upload due to an error
Sorry, this file type is not permitted for security reasons.
You have Window's line endings in your csv file. You need to replace the CRLF characters with the unix newline character.
-
Feb 1, 2014 9:39 AM in response to userremovedby Tony T1,kittersa wrote:
There is something that happens during the Automator that changes the .jpg file. They cannot be loaded into Wordpress I get an error message saying:
“Ditch_Witch_SK_300.jpg%0D” has failed to upload due to an error
Sorry, this file type is not permitted for security reasons.
Hmm.... %OD is a carriage return, so we'll use tr to get rid of it with:
NewImageName=$( echo "$NewImageName" | tr -d '\r' )
Try:
cd "$1"
while read line
do
OldImageName=${line%,*}
NewImageName=${line#*,}
NewImageName=$( echo "$NewImageName" | tr -d '\r' )
if [ -e "$OldImageName" ] ; then
mv "$OldImageName" "$NewImageName"
else
echo "$OldImageName" >> ~/Desktop/Errors.txt
fi
done <"$2"
-
Dec 27, 2015 4:28 PM in response to Tony T1by userremoved,Amazing as always.
In Numbers you wouldn't know how to add text in front of a word rather than at the end?
For example:
Ditch_Witch_SK_300.jpg > wp-content/uploads/2014/02/Ditch_Witch_SK_300.jpg
Much appreciated
-
Feb 3, 2014 6:21 AM in response to userremovedby Tony T1,In Numbers you wouldn't know how to add text in front of a word rather than at the end?
In Numbers,
enter "wp-content/uploads/2014/02/Ditch_Witch_SK_300.jpg" in the column next to "Ditch_Witch_SK_300.jpg" and then in the 3rd column enter: =C3&B3 (the & concatenates the 2 strings):
You can then convert the formula in col D to the concatenate string by selecting the column, copy (⌘C), then Paste Formula Results (⇧⌘V). and delete col B and C
-
Feb 3, 2014 7:38 AM in response to Tony T1by Tony T1,edit: s/b :
enter "wp-content/uploads/2014/02/" in the column next to "Ditch_Witch_SK_300.jpg" and then in the 3rd column enter: =C3&B3 (the & concatenates the 2 strings):
-
Mar 26, 2014 10:44 AM in response to Tony T1by bj49wd,I really appreciate this thread. I'm trying to do something similar with .wav files. I have a CSV with col 1 being a non-descript filename (HiFe_345.wav) and I want to give it a familiar name (CrowCall_02.wav) which is listed in col 2 in my CSV file.
I've set up an Automator Workflow with the Shell Script as shown.
It ran perfectly... except, all my .wav files are now considered "documents" and won't open/play.
If I manually delete the .wav extension and retype ".wav", Finder prompts me to confirm I want to change the filetype. Should I not include the file type extension in the familiar name column in my CSV? There are way too many files to manually change all the extensions... do I need to run another automator workflow?
-
Mar 26, 2014 11:40 AM in response to bj49wdby Tony T1,Check that there are no spaces in the files ext (i.e. "wav ")
-
Mar 26, 2014 12:42 PM in response to Tony T1by bj49wd,Thanks Tony,
No spaces. I tried adding a rename file extension task to the workflow.... but it still produces a "document".
Manually changing the extension properly restores the file to a working .wav file. Strange.


