Jeby
March 6th, 2009, 09:39 PM
Hi to all! :-)
I'm a Mac user, but I want to set up an ubuntu based dowload center/basic home server/basic media center. At now I'm using a MacBook Pro for all my tasks and when I need a solution for a repetitive task I use Applescript and launchd to launch the script.
For example, I've created a script that watch in a folder, search for .srt file, rename the file running "tvnamer.py", then move the renamed files in a prescribed folder and then notify me. Now I need to translate it in a scripting language compatible with linux.
First of all: what language? bash? python? I don't know, I'm only familiar with applescript... I'm not a programmer, my knowledge of scripting it's very basilar.
Then, once I've choosed the scripting language, I how can I traslate these:
tell application "Finder"
set added_items to name of every file of folder "Macintosh HD:Users:Jeby:Downloads:"
set added_items_e to name extension of every file of folder "Macintosh HD:Users:Jeby:Downloads:"
end tell
(Finder is the Mac file manager)
repeat with i from 1 to number of items in added_items
tell application "Finder"
set the the_file_name to the item i of added_items
set nameExt to item i of added_items_e
if nameExt is "srt" then
set cmd to "python tvnamer.py -ba " & quoted form of the_file_name
do shell script cmd
end if
end tell
end repeat
if the_file_name contains "]-Being Human" then
...
else if the_file_name contains "]-Forbidden Science" then
...
end if
thanks and sorry for my bad English! :-)
I'm a Mac user, but I want to set up an ubuntu based dowload center/basic home server/basic media center. At now I'm using a MacBook Pro for all my tasks and when I need a solution for a repetitive task I use Applescript and launchd to launch the script.
For example, I've created a script that watch in a folder, search for .srt file, rename the file running "tvnamer.py", then move the renamed files in a prescribed folder and then notify me. Now I need to translate it in a scripting language compatible with linux.
First of all: what language? bash? python? I don't know, I'm only familiar with applescript... I'm not a programmer, my knowledge of scripting it's very basilar.
Then, once I've choosed the scripting language, I how can I traslate these:
tell application "Finder"
set added_items to name of every file of folder "Macintosh HD:Users:Jeby:Downloads:"
set added_items_e to name extension of every file of folder "Macintosh HD:Users:Jeby:Downloads:"
end tell
(Finder is the Mac file manager)
repeat with i from 1 to number of items in added_items
tell application "Finder"
set the the_file_name to the item i of added_items
set nameExt to item i of added_items_e
if nameExt is "srt" then
set cmd to "python tvnamer.py -ba " & quoted form of the_file_name
do shell script cmd
end if
end tell
end repeat
if the_file_name contains "]-Being Human" then
...
else if the_file_name contains "]-Forbidden Science" then
...
end if
thanks and sorry for my bad English! :-)