bash - Applescript+Shell Compare list of folders to list of files and move files into subfolders -


I am trying to create an applescript which will run the script below. Transferring a file named temp_m to a folder with a name screenshot provided for reference is the benefit of easy applescript to select the "loose images" (source) folder and the build out (archive) folder for the user. Often exist in different places, sometimes at server / share.

E.G.

Enter image details here

to

Enter image details here

  set myFolder (folder Select pFolder myFolder Set the name for the paragraph of the POSIX path of the folder (Find Shell Script "PARENTDIRECTORY =" pFolder ". -Name" * .jpg "| When the file reads temp_m = $ (basename" $ ​​file " .jpg) look = $ (echo "$ PARENTDIRECTORY / * / * $ {temp_m}" | sed 's / / \\ / g') # All subfolders must be matched in this original folder , Which is the same name as Temp_m name = $ (Eval echo $ look) if [-f "$ look"] then todir = "$ {look% / *}" resonant mv "$ {temp_m}. Jpg "$ {todir} / # to copy operations - after deleting the test, Echo else echo has no unique mail for" $ look " 

You might use a shell command like this:

shopt -s nullglob; F or f ~ ~ / pictures / loose \ files / *. Jpg; F2 = $ {f ## * /}; D = ~ / picture / * / * / * / * / $ {f2% _ *}; [[$ D]] & amp; Amp; & Amp; Amp; A.K. MV "$ f" $ d; Done

shopt -s nullglob extends the file name pattern that does not match any files Expand to an empty string $ {f ##} Removes the longest * / pattern from the beginning of the f and $ {f2% _ *} < Removes the _ * pattern at the end of the code> f2 [[$ d]] [[-n $ d]] , or it tests that if $ d is set and is not set for an empty string

If the target folders can be at different nesting levels, you can see the find :

for f ~ ~ pictures / loose files / *. Jpg; Do f2 = $ {f ## * /}; D = $ (find ~ / image-type D-name $ {f2% _ *}); [[$ D]] & amp; ; & Amp; Echo MV "$ f" $ d; Done


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -