简体   繁体   中英

Can i do this with automator?

Task: in the root folder there are have some subfolders, in each of them i need to pack everything except the image file named prev in an archive named 3d and delete, so that in the end only the 3d archive and the image named prev remain in each folder, is it possible to do this?

https://i.stack.imgur.com/Cguo5.png https://i.stack.imgur.com/Tage6.png https://i.stack.imgur.com/NnnbC.png https://i.stack.imgur.com/DAP5l.png https://i.stack.imgur.com/sKUEF.png https://i.stack.imgur.com/eluSE.png

Sort of guessing at what the situation and desired outcome here is, but here's my stab at it.

Situation:

  • Folder on desktop contains multiple files

  • Text file contains list of files to keep

  • Files not in list to be zipped and trashed

Outcome:

  • Folder contains listed files

  • Folder contains zip archive containing non-listed files

     set kpFile to "im2keep.txt" set souFol to "sourco:" set pdt to ((path to desktop) as text) tell application "Finder" set flAlias to files of ((pdt & souFol as text) as alias) as alias list set filesAll to {} repeat with x in flAlias set end of filesAll to POSIX path of x end repeat end tell -- get container of files set f1 to POSIX file (item 1 of filesAll) tell application "Finder" to set cPath to POSIX path of (container of (f1 as alias) as alias) set fil2 to pdt & kpFile as text -- files to keep (zip and trash others) set flKeep to paragraphs of (read alias fil2) -- create file references for files to zip/trash set AppleScript's text item delimiters to "/" set kpFs to {} set lsFs to {} repeat with d in filesAll -- each posix file if flKeep contains contents of d then set end of kpFs to cPath & last text item of d else set end of lsFs to cPath & last text item of d end if end repeat tell application "Finder" set c0 to pdt & souFol set c1 to POSIX path of c0 set c4 to {} repeat with x in lsFs set end of c4 to x end repeat set AppleScript's text item delimiters to space set c5 to (lsFs as text) -- zip files then delete them tell me to do shell script "/usr/bin/zip -m " & c1 & "3d.zip " & c5 end tell

NB While the question does mention automator and multiple folders, since I can't be sure that I understand the question correctly, I'm just doing the applescript part for a single folder. It should however, be relatively straightforward to apply to multiple folders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM