-hans-
Jamba
- Registriert
- 02.09.10
- Beiträge
- 56
Guten Morgen 
einen hab' ich auch noch, eine (natürlich auch supischnelle
) Rubyvariante.
RubyScript auf dem Desktop ablegen:

einen hab' ich auch noch, eine (natürlich auch supischnelle

Code:
on open dropped
--RubyScript wird auf dem Desktop gesucht ...
set rubyscriptpath to POSIX path of ((path to desktop as text) & "rn.rb")
set myFileString to ""
repeat with i from 1 to count of dropped
set myFileString to myFileString & POSIX path of (item i of dropped) & ", "
end repeat
do shell script "ruby " & rubyscriptpath & " " & quoted form of myFileString & ""
end open
RubyScript auf dem Desktop ablegen:
Code:
#!/usr/bin/env ruby -w
time = Time.new
myYear = time.year
stringOfFilePaths = ARGV[0]
myArray = stringOfFilePaths.split(', ')
myArray.each do |line|
myExt = File.extname(line)
myStrippedName = File.basename(line, myExt)
myDirPath = File.dirname(line)
myNewName = "#{myDirPath}/#{myStrippedName}#{myYear}#{myExt}"
File.rename(line, myNewName)
end