Applescript moving different files to different folders

I have 377 files I need to move into 377 different folders. The files have a name like "JustAKid_Basketball-10up 2.pdf" where only the number on the end changes. The folders are named for cities with a number on the front. i.e. "374.SHALLOTTE" I'm trying to build a script that can read the file name and match number to number and then move the file into the matching folder. "JustAKid_Basketball-10up 2.pdf" would go into "2.NASHVILLE." Does that make sense? Any help would be greatly appreciated.

IF window 1 contained just exactly 377 folders and 377 files, AND IF all your files really had the same name (except for the number at the end), for example "JustAKid_Basketball-10up 1.pdf", "JustAKid_Basketball-10up 2.pdf", …, "JustAKid_Basketball-10up 376.pdf", "JustAKid_Basketball-10up 377.pdf", THEN you could try the following script:
tell application "Finder"
      set k to 377
      repeat until k = 0
            move file k of window 1 to folder k of window 1
            set k to k - 1
      end repeat
end tell

Similar Messages

  • Using AppleScript to sort files Into Specified Folders based on Extension

    Hi All!
    Here is what I am trying to figure out. I would love some help with this script if anyone can lend a helping hand. I am currently using Hazel to do this but I think AppleScript will be alot more effective.
    Situation:
    - I have a folder with 4 different file types inside - the extensions are (.cop, .cof, .cos, .cr2)
    - These files need to be organized in this folder structure  Captureone > Cache > Proxies
                                                                                                                  > Settings50
    - The .cop & .cof files both need to be put in the "Proxies" folder
    - The .cos needs to be put in the "Settings50" folder
    - The .cr2 can stay where it is.
    I'm already using an AppleScript application where it automatically creates the folder structure in the current finder location, which works great. I use a program named Hazel to sort the files automatically into the folders where they need to go. Unfortunately all my computers at work don't have Hazel and I would like help to make a script. Any thoughts to add to my existing script?
    #  define a list of folders - items will need to be quoted if they contain spaces, etc.
    property theFolders : {"Captureone/Cache/Proxies", "Captureone/Settings50"} -- can also nest, e.g. "Inside/One"
    try
              tell application "Finder" to set targetFolder to (target of the front window) as alias
    on error -- no window
              set targetFolder to (choose folder)
    end try
    # build a parameter string from the folder list
    set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, space}
    set {theFolders, AppleScript's text item delimiters} to {theFolders as text, tempTID}
    do shell script "cd " & quoted form of POSIX path of targetFolder & "; mkdir -p " & theFolders

    Hi,
    applescript_problems wrote:
    for example:
    master folder name: 1
    sub folder path: 1>2>3>4>5
    insdie folder 5 theirs 3 folders: 5a, 5b, 5c
    i want to name my files like so: "name_5a" "name_5b" "name_5c
    i want the scrip to pick up all the files that ends with the name "_5a" and place them in folder 5a
    I presume that the files are in the master folder not in the subFolders, that the files has an name extension.
    This script take the first two characters after the last underscore.
    It will move the file in the subfolder, according to the two characters found.
    set targetFolder to (POSIX file "") as alias --<-- drop the master folder between the double quotes
    tell application "Finder"
          repeat with tFile in (get files of targetFolder)
                set tName to name of tFile
                set subname to my getChar_1_2AfterLastUnderscore(tName)
                -- example : subname = "5c" -->  folder "5c" of folder "5" of targetFolder
                if subname is not "" then
                      tell folder subname of folder (text 1 of subname) of folder targetFolder
                            if exists then move tFile to it -- if exists this folder then move this file
                      end tell
                end if
          end repeat
    end tell
    on getChar_1_2AfterLastUnderscore(t)
          if "_" is in t then try
                set oTID to text item delimiters
                set text item delimiters to "_"
                set t to text 1 thru 2 of last text item of t
                set text item delimiters to oTID
                return t
          on error
                set text item delimiters to oTID
          end try
          return ""
    end getChar_1_2AfterLastUnderscore
    To get the exact path of the master folder :
    Drag/drop the folder between the double quotes in the first line of the script.

  • Moving LR files between disk folders that don't appear in Navigator but are in other LR catalogs

    I want to move LR files from one disk folder to another. The folders don't appear in the Navigator with the current catalog open.
    I can't navigate the disk hierarchy to find the other folders. I'm guessing that I need to open each catalog and move the files it's aware of, then open a different catalog and repeat. Is this correct? Would this assure that each catalog knows the locations of its own moved files?
    I was hoping there's a way to avoid combining catalogs at this time. Perhaps in the future I'd combine some or all of them
    Am I missing anything?
    Thanks.

    Ian,
    With CS3, I think you'll have to render your images as TIFF or PSD on their way to Photoshop. I'm pretty sure that the local adjustments weren't handled until the Camera Raw that came with CS4.
    There's an easy way to tell if that's the case. Open a raw file in your PS3 Camera Raw and see if there are local adjustments available.
    Hal

  • Applescript to email files from multiple folders

    I have a dictaphone that stores recordings in 5 folders. When I connect the dictaphone, it downloads all recordings to respective Folders A through to E. I need the script/s to check each folder for files and automatically email them off then move them to a sent folder. Each folder can contain one or more recordings.
    What I find with my script below is that when I apply it to each folder, one of two things will happen. Either all the files from one folder will get sent and moved or the first file from each folder gets sent and moved. Everything else stays where it is.
    I'm beginning to think the trigger "on adding folder items" might not be the best way to achieve this. Perhaps I should link it to checking for the dictaphone being plugged in then scan all subfolders for files.
    [applescript]
    on adding folder items to themailfolder after receiving theAddedItems
    repeat with eachitem in theAddedItems
    tell application "Microsoft Entourage"
    activate
    set newmessage to make new draft window with properties {to recipients:"[email protected]", subject:"My Files", attachment:{file:eachitem}}
    send newmessage
    tell application "Finder"
    move eachitem to "Macintosh HD:Users:admin:documents:myfiles:sent"
    end tell
    end tell
    end repeat
    end adding folder items to
    [applescript]
    Any input gratefully welcome!
    Message was edited by: K-Lye

    Noted - problem solved here:
    http://bbs.macscripter.net/viewtopic.php?id=26312
    Message was edited by: K-Lye

  • What is the best way to move files to different folders in a plug-in?

    I am writing a plug-in that needs to move files on the hard drive.  I am using LrFileUtils.move(from, to) and everything is fine except that the catalog is not updated when the file is moved.  After the plug-in runs I can use Library > Synchronize Folder to get the catalog back in sync with the new locations of the photos on the drive, but this manual step is less than ideal. 
    I am unable to find a way to move the files within the plug in that also updates the catalog (like dragging photos to a new location within the LR Navigator pane).  Lacking an API for this, I looked for a way to programmatic execute the Synchronize Folder menu item, but was not able to find this either..
    Can anyone recommend a better way to move photos to different folders within a plug-in that also updates the catalog?

    Hi Andy,
    There are 3 main file formats that you can consider writing your data out to in LabVIEW:
    ASCII
    Binary
    Datalog
    ASCII
    ASCII files are useful because every operating system and almost every application can read/write ASCII format files. Use ASCII files when:
    Other users or applications will need to access the data file.
    You will not need to perform random access file I/O
    File I/O speed is not crucial
    Disk space is not crucial
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write to Text File.vi and Read from Text File.vi
    Binary
    Binary byte stream files are more specific to data storage and retrieval. Use b
    inary files when:
    File I/O will remain in LabVIEW only -- no other applications will be needing to write/read that file. There is no standard formatting for binary files and thus other applications or operating systems may be unable to read the file.
    Files are smaller than ASCII files
    Easier and faster random access to data
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write Binary File.vi and Read Binary File.vi
    Datalog
    When to use datalog:
    If you need to record data with a mixture of types, it can be cumbersome to convert everything to ASCII or to keep track of the binary formatting.
    Datalog format is binary and internal to LabVIEW, so again only use this format if no other applications or operating systems will be needing to perform file I/O on the file.
    Examples within LabVIEW Example Finder: Fundamentals >> File Input and Output >> Write Datalog File
    Example.vi and Read Datalog File Example.vi
    Good luck!
    Kileen C.
    Applications Engineer
    National Instruments

  • I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    Do some testing to get your method working right with some less than important footage.
    Copy/paste files where you want then.
    Use the FCE Reconnect feature to tell FCE where the newly copied files reside.
    Make sure the new location and files are working as expected with your Projects.
    Delete the original files if no longer required.
    Al

  • I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    I recently deleted many duplicate files. In the midst of it my Itunes songs are not in Itunes. They are in two different folders. One under 'Music' in my ID. And two under a MyMusic file in Documents. How do I know which one to import?

    Thanks, this is not an ideal answer but probably the most sensible one in my case.
    I will try it unless someone has a better suggestion, but I'll wait a bit as it will take me a few days anyway (I had actually tried to create a new smaller playlist or download by album, but at this stage the music app is not letting me queue a list of songs for download - I think I will have to disable and re-enable iTunes match which will probably delete all the songs).
    I have to say I am not very impressed with Apple here - having an online backup of all your data and beeing able to restore it to a new device easily was a strong selling point of iCloud. For music, they are Definitly not delivering at the stage.

  • Importing files of the same name in *different* folders?

    Yes, yes, we all know about the RAW+JPEG and whatever else argument.
    But why should I be prevented from importing identical files that are stored in different folders? Who cares if they are in the library twice?
    I haven't figured out if it's just a name issue (don't think so) or if the files have to be truly identical.
    I *think*, but am not sure, that you can import separate files of the same name but that are actually different images. Can anyone verify?
    Lee Jay

    Bob,
    It appears that you can import duplicate named files by unchecking the "ignore Duplicates' box--the first time you import files (or a file) from a folder. But, if you go back to that folder to use 'import' to update, then the import takes place immediately bypassing the screen with the "ignore Dulicates' box on it--I presume it assumes that you would not want to change any of the original settings for an import from a given folder.
    The point is you had better leave it unchecked always if you want duplicates ingested intially or later on reimport.

  • Alter Database Remove File : Partition Files on different folders

    I need to remove partition files, once I switch the partition with staging table and empty/truncate the partition. 
    When I was running the code on my local machine I was passing variable @partition_file_name to following statement:
    Declare @partition_file_name varchar(128)='table_abc_201202',
    @database_name varchar(128)='test'
    Alter Database @database_name Remove File  @partition_file_name
    Note @partition_file_name is the logical name of the partition file.
    I found out partitions are saved in different folders in my Dev env...They are stored in 12 different folders which are named like 1-12.
    E.g:
    C:\DATA\2\table_abc_201202.ndf
    C:\DATA\3\table_abc_201203.ndf
    C:\DATA\4\table_abc_201204.ndf
    C:\DATA\5\table_abc_201205.ndf
    C:\DATA\2\table_abc_201302.ndf
    C:\DATA\3\table_abc_201303.ndf
    C:\DATA\4\table_abc_201304.ndf
    C:\DATA\5\table_abc_201305.ndf
    I am wondering , is SQL server with Alter statement is capable of getting the right path for each partition files and remove them accordingly? Or do I need to pass the physical path to the alter statement to get it removed. Though I tried doing that and
    got the error.
    ZK

    I am wondering , is SQL server with Alter statement is capable of getting the right path for each partition files and remove them accordingly? Or do I need to pass the physical path to the alter statement to get it removed. Though I tried doing that and
    got the error.
    Yes, SQL Server knows which physical file goes with which logical filename.  (To see that SQL does know this, do a SELECT * FROM sys.sysfiles - you'll see SQL has a row for every logical filename and that row has the corresponding physical file name.)
    And when you do the ALTER DATABASE REMOVE FILE, you must specify the logical filename.  You will get an error if you give the physical path.
    Tom

  • I only want itunes to hold the lossless files which are in two different folders. How do I do that?

    I have thousands of MP3 files which I no longer use and which are in my itunes library.
    I want itunes (version 11) to have in it's library only the MS Lossless format and the ALAC lossless format which are in two different folders. How do I achieve this?

    Delete the files you don't want, or cut & paste them to an alternate location if you want to archive them.
    What MS Lossless format? .wav?
    iTunes doesn't have any custom organization features, but you can change the location of the media folder and then selectively consolidate content to the new folder. This creates copies so you have to manually delete the originals. Alternatively I have a script called ConsolidateByMoving which does what it suggests. Thiis could be used to split the media into parallel subfolders within your existing media folder if you disable iTunes "Keep iTunes Media folder organized" option.
    tt2

  • One file to two different folders simultaneously?

    Is there a way to copy one file to two different folders simultaneously?
    Maybe a script?
    Drew

    Thanks for the response Baltwo.
    Maybe I shouldnt have said 'simultaneously'.
    What I'm trying to achieve is this.
    I drop a file into one folder and it automatically copies to ano folder (a redundant back up of the first folder)
    Is that possible at all?
    Drew

  • Saving jpeg and html file into different folders

    Hi, all.
    I developed a VI that generates, on a timely basis, reports (HTML format) that contain some text, numerical values and graph images (jpeg). The problem is that when it saves a HTML file to a folder, JPEG files are also saved into the same folder.
    Is there any way I can save these html and jpeg into different folders?
    Or is it even possible to generate html report with some graph images without having to have save jpeg files? (this would be even better).
    I included a screen shot of the VI.
    Thanks in advance for your help.
    Attachments:
    screen shot.doc ‏184 KB

    There is currently no way, with the Report Generation VIs, to save the image files for an HTML report to a separate folder.  If you think this would be a helpful feature, please submit your request to the Product Suggestion Center, and we will look into possibly including this feature in a future release.  For now, the only workaround I can think of would be for you to use the File I/O VIs to manually create another folder and move the image files to it, then use the string manipulation functions to edit the contents of the HTML file to point all image file references to the new location.
    As for not generating images, I don't know of an easy way to have an HTML page with images where there are not corresponding image files.
    Good luck,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Streaming files with different folders

    Hi
    i am new to FMS4 and i am having a problem playing some files with different folders.
    i have different folders in C:\media3\feeds
    in that directory i have folder "1", "2" and "3"
    other words C:\media3\feeds\1
    C:\media3\feeds\2
    C:\media3\feeds\3
    in config folder i changed fms.ini
    VOD_DIR = C:\media3\feeds\
    and
    VOD_COMMON_DIR = C:\media3\feeds\
    i only got the f4v files to work in C:\media3\feeds\ which link is rtmp://localhost/vod/mp4:testfile.f4v
    so i tired to have some folders in C:\media3\feeds\ like mention above
    i tried to put <Streams>/;<C:\media3\feeds\1</Streams> in Applications.xml file in the C:\Program Files\Adobe\Flash Media Server 4\applications\vod
    and used rtmp://localhost/vod/1/mp4:testfile.f4v
    here is piece of the App file
    <Application>
    <StreamManager>
    <VirtualDirectory>
          <!-- Specifies application specific virtual directory mapping for recorded streams.   -->
    <Streams>/;${VOD_COMMON_DIR}</Streams>
    <Streams>/;${VOD_DIR}</Streams>
    <Streams>/;<C:\media3\feeds\1</Streams>
    <Streams>/;<C:\media3\feeds\2</Streams>
    </VirtualDirectory>
    nothing worked
    can some one help me with this??

    If you are using
    VOD_DIR = C:\media3\feeds\ or VOD_COMMON_DIR = C:\media3\feeds\
    and having files in folder "1" which is under "C:\media3\feeds\"
    then you URI should be rtmp://localhost/vod/mp4:1/testfile.f4v (where testfile.f4v is present under C:\media3\feeds\1)
    If you are using
    <Streams>/;C:\media3\feeds\1</Streams>
    <Streams>/;C:\media3\feeds\2</Streams>
    Then your URI should be rtmp://localhost/vod/mp4:testfile.f4v  (where testfile.f4v is present under C:\media3\feeds\1 or C:\media3\feeds\2)
    Also please note in your configuration which you have specified
    <Streams>/;<C:\media3\feeds\1</Streams><Streams>/;<C:\media3\feeds\2</Streams>
     please remove "<" in "<C:\media3\feeds\1" and "<C:\media3\feeds\2"

  • I can't move music files to different folders in my itunes library

    First, I have not created files in my itunes library for a while, and I could swear it was a lot easier years ago! ALL that I want to do is add the new music I've purchased or recently added to a folder that already exists in the playlist.
    1) All my recently added songs have been purchased through my iphone, I'd like to move them to a folder.
    2) When I connect my phone to my computer, I see the tab to click on my phone. I do, and it opens the content of Music in my iphone.
    3) In this content, there are folders to the left listed, beginning with Music, Movies, Purchased, Recently Added, Recently Played, "My Name" Favorites, another specific folder I labeled to seperate music, and then another Purchased folder.
    4) I WANT TO MOVE or copy my newly purchased music file to these folders so when I play them on my phone, I can SIMPLY choose the file that is asscoiated with my Favorites or other choice.
    Why Is This So Difficult to do! Or is it that easy and I'm overlooking the past hour I've spent trying!
    Second part of my aggravation, why can i NOT sort the files in a music folder by song name anymore?! We used to be able to click at the top of the listing, Name, Aritist, Albulm etc. to sort them alphabetically and make a search easier depending on , but now I can no longer do this.

    This happened to me too but I only tried one song and then gave up. I thought it was a fairly popular song.

  • Presets in different folders MUST have unique name? WHY?

    You cannot have the same name on a preset, even though they reside in separate folders. At the filesystem level they are in different directories.
    OS file systems allow you to have the same file name as long as it is NOT in the same folder.
    To get around this, you must make each preset name different by one char, even though they are in different folders both in LR and on the OS FS.
    Why is this important to me?
    When shooting youth baseball, I would like to have five different folders of presets that represent a certain time of the day, as great preset for noon does not work for a picture take at 5pm in the evening..
    So 5 folders, 9a-12p, 12p-3p, 3p-5p, so on..
    Each folder would have 10-15 presets for quick develop settings based on where on the field I am shooting.
    Open up a game shot in the morning, open the preset folder of 9a-12p, the presets are the same name, but adjusted for the time of the day..
    .*Sigh*.
    Mac Pro 2.66, OS 10.4.10, LR 1.1

    In Lion and Mountain Lion the Home/Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    To open your domain file in Lion or Mountain Lion or to switch between multiple domain files Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    You can download an already compiled version with this link: iWeb Switch Domain.
    Just launch the application, find and select the domain file in your Home/Library/Application Support/iWeb folder that you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

Maybe you are looking for

  • Using iPod in Target Disk Mode

    Hi all. I have a Powerbook G4 and am being asked to fix a friend's iBook G4. I want to connect the PB and iB together via firewire and boot the iB in target disk mode. My question is, could I back up the contents of their hard drive to my iPod hooked

  • About jdbc receiver adatper

    the format for jdbc receiver adapter have to be the following: <root>    <statement1>   <statement1/>   <statement2>   <statement2/> <root/> can i instert the element defined by myself between <root> and <statement1>. like: <root> <sqlset>    <statem

  • Infix to Postfix calculation: having problems.. help?

    This is a program that when you input infix expression, it converts it to postfix expressions the evaluates the postfix.. I'm having difficulty in my main method. How do i loop it? when the user wants to another input an expression?.. import java.io.

  • HT1695 my iPhone wont connect to any wifi connections

    I have an iPhone 4S and anywhere I go and try to connect to the internet, if I type in the password it says "incorrect password". I have typed in the password correctly and it doesn't work at my house, work, or basically anywhere else. My brother has

  • Lens won't Stick

    I replaced the housing on my 8520 and the lens refuses to stay stuck on.  Any suggestions on what kind of adhesive I can use to stick it on?