create folders applescript

Discussion in 'Mac Programming' started by joennie, Jul 29, 2013.

  1. macrumors newbie

    Joined:
    Jul 29, 2013
    #1
    I have a folder with x ammount of subfolders which all contain images.

    I need to create the same folder structure but within each folder I need to create a 2 folders, thumbnails and fullsize images and then process each original folder and insert the images into the correct folders

    Current format

    main folder > imagefolderone > img1
    img2
    img3

    imagefolderone > img1
    img2
    img3

    Required format

    main folder > imagefolderone > thumbnail_folder >
    thumbnail image1
    thumbnail image2
    thumbnail image3
    main_folder >
    main image1
    main image2
    main image3

    > imagefoldertwo > thumbnail_folder >
    thumbnail image1
    thumbnail image2
    thumbnail image3
    main_folder >
    main image1
    main image2
    main image3
     
  2. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #2
    There are several different ways to create folder structures, but sometimes it is easier to create the desired structure using the normal Finder commands, and then copy the template as needed.

    Code:
    on run -- example
    	copyFolderStructure from (choose folder with prompt "choose source folder") to (choose folder with prompt "choose destination folder")
    end run
    
    to copyFolderStructure from sourceFolder to destinationFolder
    	tell application "Finder"
    		repeat with someFolder in (get folders of sourceFolder)
    			get name of someFolder
    			try
    				make new folder at destinationFolder with properties {name:result}
    			on error number -48 -- ignore duplicate file name, but continue traversing the structure
    				get ((destinationFolder as text) & result) as alias
    			end try
    			my (copyFolderStructure from someFolder to result)
    		end repeat
    	end tell
    	return
    end copyFolderStructure
     
  3. thread starter macrumors newbie

    Joined:
    Jul 29, 2013
    #3
    Thanks so much...if I want to add a generic thumbnail folder, would that be done in the same code, or would I run a separate applescript
     
  4. macrumors 6502

    Joined:
    May 29, 2011
    Location:
    Littleton, Colorado, USA
    #4
    You can add folders to the template and use the same script to update an existing structure.
     

Share This Page