In the Move Items dialog, select the folder where you want to move all the files. To create a new folder, click the Make New Folder button and give the folder name accordingly. Once selected the folder, click Move. This moves all the files recursively from the multiple sub-folders to the destination folder chosen. Method 4: Using 7-Zip. 1 - Open the main top level folder. 2 - In the search box, type a single asterisk (. ) which will cause all files from that point downward (in any subfolder) to show up in the search results, regardless of which folder they are in. 3 - Drag all the search result files to their new home. You can filter by file type too. Unzip multiple files in same directory on Mac OS X If you have multiple zip files in a directory and you want to extract all of them at once into that directory, then simply do Open Spotlight and enter “Terminal” then enter the following. It’s generally good practice to avoid hard-coding file and folder paths in a script. Prompting the user to select files and folders makes for a more dynamic script that won’t break when paths change. Prompting for a File. Use the Standard Additions scripting addition’s choose file command to prompt the user to select a file. Need a way to merge folders and treat files in the following manners: (1) If the two same-named files are the same, keep a copy of the file. (2) If the two same-names files are NOT the same, keep both copies. (3) If the file does NOT exist in the destination folder, move the file from source folder to destination folder. Is this possible?
Prompting for Files or Folders
It’s generally good practice to avoid hard-coding file and folder paths in a script. Prompting the user to select files and folders makes for a more dynamic script that won’t break when paths change.
Prompting for a File
Use the Standard Additions scripting addition’s choose file
command to prompt the user to select a file. Listing 26-1 and Listing 26-2 demonstrate how to use this command to display the simple file selection dialog with a custom prompt shown in Figure 26-1.
APPLESCRIPT
Listing 26-1AppleScript: Prompting for a fileset theDocument to choose file with prompt 'Please select a document to process:'
--> Result: alias 'Macintosh HD:Users:yourUserName:Documents:ImportantDoc.pages'
JAVASCRIPT
Listing 26-2JavaScript: Prompting for a filevar app = Application.currentApplication()
app.includeStandardAdditions = true
var document = app.chooseFile({
withPrompt: 'Please select a document to process:'
})
document
// Result: Path('/Users/yourUserName/Documents/ImportantDoc.pages')
Prompting for a Specific Type of File
If your script requires specific types of files for processing, you can use the choose file
command’s optional of type
parameter to provide a list of acceptable types. Types may be specified as extension strings without the leading period (such as 'jpg'
or 'png'
) or as uniform type identifiers (such as 'public.image'
or 'com.apple.iwork.pages.sffpages'
). Listing 26-3 and Listing 26-4 show how to prompt for an image.
APPLESCRIPT
Listing 26-3AppleScript: Prompting for an imageset theImage to choose file with prompt 'Please select an image to process:' of type {'public.image'}
--> Result: alias 'Macintosh HD:Users:yourUserName:Pictures:IMG_0024.jpg'
JAVASCRIPT
Listing 26-4JavaScript: Prompting for an imagevar app = Application.currentApplication()
app.includeStandardAdditions = true
var image = app.chooseFile({
withPrompt: 'Please select an image to process:',
ofType: ['public.image']
})
image
// Result: Path('/Users/yourUserName/Pictures/IMG_0024.jpg')
Prompting for Multiple Files
To let the user choose more than one file, include the choose file
command’s optional multiple selections allowed
parameter. Listing 26-5 and Listing 26-6 display a prompt asking for multiple images, as shown in Figure 26-2.
APPLESCRIPT
Listing 26-5AppleScript: Prompting for multiple imagesset theImages to choose file with prompt 'Please select some images to process:' of type {'public.image'} with multiple selections allowed
--> Result: {alias 'Macintosh HD:Users:yourUserName:Pictures:IMG_0024.jpg', alias 'Macintosh HD:Users:yourUserName:Pictures:IMG_0025.jpg', alias 'Macintosh HD:Users:yourUserName:Pictures:IMG_0026.jpg'}
JAVASCRIPT
Listing 26-6JavaScript: Prompting for multiple imagesvar app = Application.currentApplication()
app.includeStandardAdditions = true
var images = app.chooseFile({
withPrompt: 'Please select some images to process:',
ofType: ['public.image'],
multipleSelectionsAllowed: true
})
images
// Result: [Path('/Users/yourUserName/Pictures/IMG_0024.jpg'), Path('/Users/yourUserName/Pictures/IMG_0025.jpg'), Path('/Users/yourUserName/Pictures/IMG_0026.jpg')]
Prompting for a Folder
Use the Standard Additions scripting addition’s choose folder
command to prompt the user to select a folder, such as an output folder or folder of images to process. Listing 26-7 and Listing 26-8 demonstrate how to use this command to display the simple folder selection dialog with a custom prompt shown in Figure 26-3.
APPLESCRIPT
Listing 26-7AppleScript: Prompting for a folderset theOutputFolder to choose folder with prompt 'Please select an output folder:'
--> Result: alias 'Macintosh HD:Users:yourUserName:Desktop:'
JAVASCRIPT
Listing 26-8JavaScript: Prompting for a foldervar app = Application.currentApplication()
app.includeStandardAdditions = true
var outputFolder = app.chooseFolder({
withPrompt: 'Please select an output folder:'
})
outputFolder
// Result: Path('/Users/yourUserName/Desktop')
Prompting for Multiple Folders
Extract Files From Folders Windows
To let the user choose more than one folder, include the choose folder
command’s optional multiple selections allowed
parameter, as shown in Listing 26-9 and Listing 26-10.
APPLESCRIPT
Listing 26-9AppleScript: Prompting for multiple foldersset theFoldersToProcess to choose folder with prompt 'Please select the folders containing images to process:' with multiple selections allowed
--> Result: {alias 'Macintosh HD:Users:yourUserName:Desktop:', alias 'Macintosh HD:Users:yourUserName:Documents:'}
JAVASCRIPT
Extract Multiple Zip Folders
Listing 26-10JavaScript: Prompting for multiple foldersHow To Extract Multiple Folders
var app = Application.currentApplication()
app.includeStandardAdditions = true
var foldersToProcess = app.chooseFolder({
withPrompt: 'Please select an output folder:',
multipleSelectionsAllowed: true
})
foldersToProcess
// Result: [Path('/Users/yourUserName/Desktop'), Path('/Users/yourUserName/Documents')]
How Do I Extract Files From Multiple Folders On A Mac
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-06-13