• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: creation of Folders from File names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creation of Folders from File names


  • Subject: Re: creation of Folders from File names
  • From: Ronald Hofmann <email@hidden>
  • Date: Sat, 03 Sep 2011 17:44:59 +0200

Hi Ted,
I don´t think that this is something you can do with automator.

But anyway, it´s not too hard to do it with AppleScript.
Here my script (attached as File)

property theOrigin : AppleScript's text item delimiters

set theFolderPath to choose folder with prompt "Select a Folder with Files…"

tell application "Finder"
set theFileList to files in theFolderPath
end tell

repeat with thisItem in theFileList
set theFilePath to thisItem as text
set infoForThisItem to info for file theFilePath
set theFileName to name of infoForThisItem
set theFileExtension to name extension of infoForThisItem
set theFileExtension to "." & name extension of infoForThisItem
set theNewFolderName to replaceTextInAString(theFileName, theFileExtension, "")


tell application "Finder"
set theNewFolder to (make new folder at theFolderPath with properties {name:theNewFolderName})
move thisItem to theNewFolder
end tell


end repeat

(*  Replaces in Text theTextToChng the string search_string by replacement_string  *)
on replaceTextInAString(theTextToChng, search_string, replacement_string) -- 
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of theTextToChng
set AppleScript's text item delimiters to the replacement_string
set theTextToChng to the item_list as string
set AppleScript's text item delimiters to theOrigin
return theTextToChng
end replaceTextInAString

Attachment: PutFilesInFoldersWithSameName.scpt
Description: Binary data

Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
References: 
 >creation of Folders from File names (From: ted godwin <email@hidden>)

  • Prev by Date: creation of Folders from File names
  • Next by Date: RE: INDESIGN: Updating Links Not Working
  • Previous by thread: creation of Folders from File names
  • Next by thread: egrep explanation needed
  • Index(es):
    • Date
    • Thread