Copy and move files (Excel and Finder)

I heve folder with the picture and excel with the numbers of picture. How select picture and move?

  1. Select numbers with column A2:A6 (Excel)
    Numbers in Excel correspond to the numbers of photos in Finder
  2. Create folder "1"
  3. Move this picture (3.jpg, 7.jpg, 11.jpg, 15.jpg, 18.jpg,) to folder "1"

Hey @kamilek,

This AppleScript will do that.

Run from an Execute an AppleScript action (test using the Script Editor.app).

Always make sure you have a backup before testing.

-Chris


Non-Recursively Find Files Using a Regular Expression and Move to a Folder.scptd.zip (13.2 KB)

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/05/08 07:01
# dMod: 2016/07/29 16:26
# Appl: AppleScriptObjC
# Task: Non-Recursively Find Files Using a Regular Expression and Move to a Folder; RegEx ; Handler
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Finder, @Find, @Files, @RegEx
--------------------------------------------------------------------------------
use framework "Foundation"
use scripting additions
--------------------------------------------------------------------------------
# Set your source and destination folder paths:
--------------------------------------------------------------------------------
set srcDirPath to "~/test_directory/kamilek_test/"
set destDirPath to "~/test_directory/kamilek_test/brak rzeczy/"
--------------------------------------------------------------------------------

set srcDirPath to current application's NSString's stringWithString:srcDirPath
set srcDirPath to srcDirPath's stringByExpandingTildeInPath() as string
set destDirPath to current application's NSString's stringWithString:destDirPath
set destDirPath to destDirPath's stringByExpandingTildeInPath() as string
set destDirPath to alias POSIX file destDirPath

set foundFileList to its findFilesWithRegEx:"^(3|7|11|15|18)\\.jpg$" inDir:srcDirPath

if foundFileList ≠ {} then
   
   repeat with theFile in foundFileList
      set contents of theFile to alias POSIX file theFile
   end repeat
   
   tell application "Finder"
      move foundFileList to destDirPath
   end tell
   
end if

--------------------------------------------------------------------------------
--» HANDLERS
--------------------------------------------------------------------------------
on findFilesWithRegEx:findPattern inDir:srcDirPath
   set fileManager to current application's NSFileManager's defaultManager()
   set sourceURL to current application's |NSURL|'s fileURLWithPath:srcDirPath
   set theURLs to fileManager's contentsOfDirectoryAtURL:sourceURL includingPropertiesForKeys:{} options:(current application's NSDirectoryEnumerationSkipsHiddenFiles) |error|:(missing value)
   set theURLs to theURLs's allObjects()
   set foundItemList to current application's NSPredicate's predicateWithFormat_("lastPathComponent matches %@", findPattern)
   set foundItemList to theURLs's filteredArrayUsingPredicate:foundItemList
   set foundItemList to (foundItemList's valueForKey:"path") as list
end findFilesWithRegEx:inDir:
--------------------------------------------------------------------------------

Work great, thx:grinning: