Reputation: 6102
I have some software that exports a file called My Library.bib
to a folder called thesis
. Assume that the name of the exported file is fixed. Every time I export such a file, I want to:
MyLibrary.bib
if they exist.MyLibrary.bib
.I've tried making an Automator 'folder action' as follows:
... However, while the shell script works perfectly if run manually, the folder action itself never appears to trigger.
Folder actions are nonetheless enabled (see below settings), and other folder actions do seem to work.
Summarily, I just want any files named My Library.bib
entering the thesis
folder (at any time, automatically) to become renamed to MyLibrary.bib
, replacing any existing MyLibrary.bib
files. Any ideas what's going wrong, or how else to achieve this? Thanks in advance.
Upvotes: 1
Views: 1095
Reputation: 7191
When you use the "Run Shell Script" action, the current directory is the Home folder, not the "thesis" folder.
So, you must use the cd
command to change the current directory
Informations:
rm
command is not necessary, you can use the mv -f
to
overwrite an existing fileread firstLine ### get the path of the first dropped item
myDir=$(dirname "$firstLine") ### get the parent (this folder action)
cd "$myDir" && if [ -f "My Library.bib" ]; then
mv -f "My Library.bib" "MyLibrary.bib"
fi
Upvotes: 1