Dateien eines bestimmten Typs verschieben und Ordnerstruktur dabei beibehalten

Das war die Aufgabenstellung, damit die Ordnerstruktur der Kamera zwar beibehalten wird, jpgs und raw Dateien aber getrennt abgelegt werden:

set thesource to quoted form of POSIX path of (choose folder)

set thedestination to quoted form of POSIX path of (choose folder)

set thesuffix to "'*.jpg'"

set thelist to get_folder_and_file_list(thesuffix, thesource)

set filecount to count of every paragraph of item 2 of thelist

display dialog filecount & " files have been moved" as text


make_folders_of_list(thedestination, every paragraph of (item 1 of thelist))

move_files_to_folders(thesource, thedestination, every paragraph of (item 2 of thelist))


on move_files_to_folders(thesource_folder, destination_folder, filelist)

repeat with thefile in filelist

do shell script "cd " & destination_folder & ";mv " & thesource_folder & quoted form of thefile & " " & quoted form of thefile

end repeat

end move_files_to_folders


on make_folders_of_list(destination_folder, folderlist)

repeat with thefolderpath in folderlist

do shell script "cd " & destination_folder & ";mkdir -p " & quoted form of thefolderpath

end repeat

end make_folders_of_list


on get_folder_and_file_list(searchstring, folder2search)

set folderlist to do shell script "cd " & folder2search & ";find . -iname " & searchstring & " -exec dirname {} \\;"

set filelist to do shell script "cd " & folder2search & ";find . -name " & searchstring

return {folderlist, filelist}

end get_folder_and_file_list

This entry was posted in AppleScript, Useful Snippets. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


two − 1 =

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...