Walk through all files in a folder and do this for all subfolders and...

... and their subfolders, etc. I mean I want to recursively walk through all subfolders of a folder and when I'm "in" in each folder I would like to walk through all files alphabetically of that folder.
While iterating through the files (of a certain type: .mp3, .mp4, .m4a) of that folder, I need to make a simple counter. e.g. when counter is 3 it means we are on the 3rd file alphabetically of the folder.
Then I simply want to set the track # mp3 tag of that file to this counter value (e.g. 3)
Anyone know how to do this? or at least to be able to show me the walking the folders and iterating the files bit? I'm brand new to applescript.
Why do I want to do this? Well I have a lot of live music shows, each in its own folder, but in my apple devices and itunes when I play a show it will not show the songs in the correct order. The file names are alphabetical in the correct order though and I suspect if I assign track #s then itunes, ipods and iphones will be able to play the "album" back in the order listed by track #??

What are you using to play your items? iTunes can use various properties to sort a playlist, independent of what the file name is (Finder too, for that matter). If you are just wanting to add a prefix number to a file name, you would also probably need to use leading zeros to keep it in order when sorted by name.
The following is a general purpose handler to go through the items in a folder - I just put various text into the output list as an example.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
set TheFolders to (choose folder with multiple selections allowed)
choose from list (ProcessStuff from TheFolders)
end run
to ProcessStuff from SomeItems
process items contained in SomeItems, recursively descending the directory tree
parameters - SomeItems [list]: the items to process
  returns [list]: a list of processed items
set FilesList to {} -- this will be a list of processed items
repeat with AnItem in SomeItems
set AnItem to AnItem as text -- get the contents
set FileInfo to (info for AnItem as alias) -- see Standard Additions
if (folder of FileInfo) and not (package folder of FileInfo) then -- a folder (not a package)
-- do something with the folder, if desired
set the end of FilesList to "folder  " & AnItem
try -- sort and process contents, skipping any errors
tell application "Finder"
set SubItems to (get items of folder AnItem)
set SubItems to (sort SubItems by name) as alias list
end tell
set FilesList to FilesList & (ProcessStuff from SubItems)
end try
else -- a file
-- do something with the file, if desired
set the end of FilesList to tab & (name of FileInfo)
end if
end repeat
return FilesList
end ProcessStuff
</pre>

Similar Messages

  • How do I make a text box solid if the value in the field is greater than 0 and do this for all recor

    Hello,
    I have several text boxes on a document, and wish to make the boxes either solid or visible if the value in the field is greater than 0.
    I am using an excel file for the data, each cell with either 1 or 0 (true or false).
    Any help would be appreciated.
    Thanks,
    BJ

    Yes, I also sent an email regarding this problem.
    I am using XNET to write a custom device for PXI-8516 LIN card.
    I've attached a couple snippets showing where I've tracked the problem.
    The only error that I've seen comes from the XNET Wait vi in the timeout snippet.  I believe that error occurs because frame queued in the write snippet is never transmitted by the LIN card.
    Attachments:
    Timeout_Error_Snippet.png ‏22 KB
    XNET_Write_Snippet.png ‏24 KB

  • Setting visible lines and blank rows for all users

    At Item Level for Shopping Cart, Confirmation and Invoice Creation there are settings for Number of Visible Rows and Number of Blank Lines (In Settings/Advanced Settings).
    How can this be changed for all users?

    Hi
    This is a user specific settings to be performed. in SRM 7.0
    Please prepare a document and educate the user to do. This is  the best solution
    Second Solution
    In Setting tabs there are two tabs -Basic Setting and Advance Setting
    check the webdynpro components and hide this for all users
    Regards
    G.Ganesh Kumar

  • Script to search all files in specified folder for multiple string text values listed in a source file and output each match to one single results txt file

    I have been searching high and low for this one.  I have a vbscript that can successfully perform the function if one file is listed.  It does a Wscript.echo on the results and if I run this via command using cscript, I can output to a text file
    that way.  However, I cannot seem to get it to work properly if I want it to search ALL the files in the folder.  At one point, I was able to have it create the output file and appear as if it worked, but it never showed any results when the script
    was executed and folder was scanned.  So I am going back to the drawing board and starting from the beginning.
    I also have a txt file that contains the list of string text entries I would like it to search for.  Just for testing, I placed 4 lines of sample text and one single matching text in various target files and nothing comes back.  The current script
    I use for each file has been executed with a few hundred string text lines I want it to search against to well over one thousand.  It might take awhile, but it works every time. The purpose is to let this run against various log files in a folder and
    let it search.  There is no deleting, moving, changing of either the target folder/files to run against, nor of the file that contains the strings to search for.  It is a search (read) only function, going thru the entire contents of the folder and
    when done, performs the loop function and onto the next file to repeat the process until all files are searched.  When completed, instead of running a cscript to execute the script and outputting the results to text, I am trying to create that as part
    of the overall script.  Saving yet another step for me to do.
    My current script is set to append to the same results file and will echo [name of file I am searching]:  No errors found.  Otherwise, the
    output shows the filename and the string text that matched.  Because the results append to it, I can only run the script against each file separately or create individual output names.  I would rather not do that if I could include it all in one.
     This would also free me from babysitting it and running each file script separately upon the other's completion.  I can continue with my job and come back later and view the completed report all in one.  So
    if I could perform this on an entire folder, then I would want the entries to include the filename, the line number that the match occurred on in that file and the string text that was matched (each occurrence).  I don't want the entire line to be listed
    where the error was, just the match itself.
    Example:  (In the event this doesn't display correctly below, each match, it's corresponding filename and line number all go together on the same line.  It somehow posted the example jumbled when I listed it) 
    File1.txt Line 54 
    Job terminated unexpectedly
     File1.txt Line 58 Process not completed
    File1.txt
    Line 101 User input not provided
    File1.txt
    Line 105  Process not completed
    File2.txt
    No errors found
    File3.txt
    Line 35 No tape media found
    File3.txt
    Line 156 Bad surface media
    File3.txt Line 188
    Process terminated
    Those are just random fake examples for this post.
    This allows me to perform analysis on a set of files for various projects I am doing.  Later on, when the entire search is completed, I can go back to the results file and look and see what files had items I wish to follow up on.  Therefore, the
    line number that each match was found on will allow me to see the big picture of what was going on when the entry was logged.
    I actually import the results file into a spreadsheet, where further information is stored regarding each individual text string I am using.  Very useful.
    If you know how I can successfully achieve this in one script, please share.  I have seen plenty of posts out there where people have requested all different aspects of it, but I have yet to see it all put together in one and work successfully.
    Thanks for helping.

    I'm sorry.  I was so consumed in locating the issue that I completely overlooked posting what exactly I was needing  help with.   I did have one created, but I came across one that seemed more organized than what I originally created.  Later
    on I would learn that I had an error in log location on my original script and therefore thought it wasn't working properly.  Now that I am thinking that I am pretty close to achieving what I want with this one, I am just going to stick with it.
    However, I could still use help on it.  I am not sure what I did not set correctly or perhaps overlooking as a typing error that my very last line of this throws an "Expected Statement" error.  If I end with End, then it still gives same
    results.
    So to give credit where I located this:
    http://vbscriptwmi.uw.hu/ch12lev1sec7.html
    I then adjusted it for what I was doing.
    What this does does is it searches thru log files in a directory you specify when prompted.  It looks for words that are contained in another file; objFile2, and outputs the results of all matching words in each of those log files to another file:  errors.log
    Once all files are scanned to the end, the objects are closed and then a message is echoed letting you know (whether there errors found or not), so you know the script has been completed.
    What I had hoped to achieve was an output to the errors.log (when matches were found) the file name, the line number that match was located on in that file and what was the actual string text (not the whole line) that matched.  That way, I can go directly
    to each instance for particular events if further analysis is needed later on.
    So I could use help on what statement should I be closing this with.  What event, events or error did I overlook that I keep getting prompted for that.  Any help would be appreciated.
    Option Explicit
    'Prompt user for the log file they want to search
    Dim varLogPath
    varLogPath = InputBox("Enter the complete path of the logs folder.")
    'Create filesystem object
    Dim oFSO
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    'Creates the output file that will contain errors found during search
    Dim oTSOut
    Set oTSOut = oFSO.CreateTextFile("c:\Scripts\errors.log")
    'Loop through each file in the folder
    Dim oFile, varFoundNone
    VarFoundNone = True
    For Each oFile In oFSO.GetFolder(varLogPath).Files
        'Verifies files scanned are log files
        If LCase(Right(oFile.Name,3)) = "log" Then
            'Open the log file
            Dim oTS
            oTS = oFSO.OpenTextFile(oFile.Path)
            'Sets the file log that contains error list to look for
            Dim oFile2
            Set oFile2 = oFSO.OpenTextFile("c:\Scripts\livescan\lserrors.txt", ForReading)
            'Begin reading each line of the textstream
            Dim varLine
            Do Until oTS.AtEndOfStream
                varLine = oTS.ReadLine
                Set objRegEx = CreateObject("VBScript.RegExp")
                objRegEx.Global = True  
                Dim colMatches, strName, strText
                Do Until oErrors.AtEndOfStream
                    strName = oFile2.ReadLine
                    objRegEx.Pattern = ".{0,}" & strName & ".{0,}\n"
                    Set colMatches = objRegEx.Execute(varLine)  
                    If colMatches.Count > 0 Then
                        For Each strMatch in colMatches 
                            strText = strText & strMatch.Value
                            WScript.Echo "Errors found."
                            oTSOut.WriteLine oFile.Name, varLine.Line, varLine
                            VarFoundNone = False
                        Next
                    End If
                Loop
                oTS.Close
                oFile2.Close
                oTSOut.Close
                Exit Do
                If VarFoundNone = True Then
                    WScript.Echo "No errors found."
                Else
                    WScript.Echo "Errors found.  Check logfile for more info."
                End If
        End if

  • Show Thumbnail of all files in a folder and its subfolders

    Hi Guys,
    I want to set the Filter Panel (Adobe Bridge CS3) to "show all items in this folder and all its subfolders" through Java script on windows.
    From UI it is possible by clicking on icon buton present in the filter panel and content panel shows the files from current folder as well as from its subfolders.
    Can any one suggest some Java script to do it?
    -P. M. Mitchell

    Any solution?
    Good Luck.
    My
    Si
    tes

  • I need applescript to change all files in a folder and its subfolders ending in .xlsx changed to .xlsb

    I need applescript to change all files in a folder and its subfolders ending in .xlsx changed to .xlsb

    try something like this:
    with timeout of 3600 seconds
      -- long timeout to because the Finder is horribly slow
              tell application "Finder"
      -- collects the files from a folder called "whatever" in your user home folder
                        set xlsbFiles to every file of entire contents of folder "Whatever" of home whose name extension is "xlsb"
                        repeat with thisFile in xlsbFiles
                                  set name extension of thisFile to "xlsx"
                        end repeat
              end tell
    end timeout
    you could make a more efficient script using System Events.app, but this will get the job done with a minimum of thought.

  • I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library.

    I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library. 
    I don't see anything in Help that shows when you already have transfered all the files over.  Why would it want to erase and sync when I already have all the music folder copied over?  I didn't have an issue when I had another technician copy from one laptop to another.  Home sharing is also on but not being recognized.

    I suspect you only migrated the media folder instead of the complete working library. Either review the transfer process and copy over the entire iTunes folder from your old profile's music folder or see Recovering your iTunes library from your iPod or iOS device.
    tt2

  • I restarted my mac and many apps and files disappeared. It's like it booted to a state several months ago. My CS 5 apps are not in the dock or applications folder. Has this ever happened before and what can I do?

    It's like it booted to a state it was in several months ago. My CS 5 apps are not in the dock or applications folder. Has this ever happened before and what can I do?
    The files on my desktop are not the ones that were there when I shut down. It's like it's gone back in time.
    My display's power supply got fried (I think) in a power outage so I bought a new one. However, every time I restart the display usually stays black. I have found I need to keep rebooting until it kicks in and starts working. I unplug everything, wait a while (a few minutes to overnight) and try booting again.
    This last time the display finally came on but I'm faced with this problem. I used to use time machine, but I deleted everything and disabled it a couple months ago or more so I'm at aloss as to why the mac is booting into the state it was in sevearl months ago.
    What could I have done to cause this? Has this ever happened to anyone else and is there a solution?
    Note: I did a search for a file I knew was created today. I found it and it showed that it was a file I had saved on the desktop this morning--even though that file's icon is not appearing on the desktop now.
    I did a search for photoshop and saw my CS5 version listed.
    However, I did a couple more searches and these files no longer appear in the search. I don't know if they're there or not. This is bizarre!
    I'm on a Mac Pro, 10.6.2.

    Thanks for the obvious question. I mean it. The very same thought came to me this morning and, sure enough, I had booted into another drive--my old one that, of course, had the old desktop, etc.
    It didn't dawn on me that this was the case since I hadn't set it as a boot drive but I guess in the course of all the restarts I did, it got switched.
    I'm back to normal again.

  • [Solved] Foreach loop that loops over all files in a folder does not consider first file found

    Hello,
    I have a foreach loop in SSIS (as part of Visual Studio 10 and with SQL Server 2012).
    It loops over all files in a folder (ForEach File Enumerator).
    I set the folder: OK
    Traverse Sub folders: OK
    I have set up a Variable in Variable Mappings called FileName so it shows User::FileName: OK
    Index of variable is 0: OK
    It almost works ok. Except that the first file it finds is never considered.
    I set a breakpoint then and the first file it finds, is shown in black in the watch variable window. All subsequent files found are shown in red font. When I change the names of the files so another file is the first file found then it skips the other one
    which now is the first file.
    What is going on here? Why does SSIS skip the first file it finds in a foreach file loop?
    Any suggestions highly appreciated.
    Thank you
    Andi
    Andreas

    "red font - interesting, any example to show us (image)
    It would be interesting to share with us whether you use any file masks or expressions.
    Arthur
    MyBlog
    Twitter
    It appears a variable value turns red when it changes between breakpoints. It started black for the first value (the first file, obtained BEFORE the execution reached the breakpoint), and then turned red. I was able to reproduce this behavior on a test environment.
    However, it did not skip any files.
    OP, please set up the test shown in the image below. Create a breakpoint in the sequence container for the "OnPreExecute" event.

  • 10.6.4:  how to unlock all files in a folder

    hi,
    how do you unlock all files inside a folder?
    thank you..

    thank you.. (I wonder why you can't just do it by getting info on the folder, then saying, unlock all files inside.. (u can do like that in windows) this is always more practical than having to select all files (and accidentally opening them, or something...-) in windows you can select a folder and then say, (un)lock all files and and dirs -- and subdirs and files inside -- inside this folder.. can u do something like this in mac os? if not, that's not very good.. (I guess on the mac would need to find unix commands for doing something like this..)
    they really need to consider this for future versions, this is a no-brainer...;-)
    thank you..

  • Add all files of one folder to aperture by running a script

    HI,
    i have a question:
    I will make my Aperture Tethered more easy (with my Canon eos 30D) i have coded a script / folder action to do this but: this folder action does not import all pictures (wy ever, i think that the files coming in to fast were not recognized).
    Now i will code a script which will include all files of a folder to aperture when it is run.
    i will give it a try, and the import does function, but, i don't know how i can tell the script which files it should import (with a folder action its easy, with this line:
    on adding folder items to this_folder after receiving these_items
    but how to do this without the "on adding folder items" cause that does not happen in the case i will use it.
    i'm looking forward to anthers:D
    Best Regards
    Christoph

    yes i tryed this application, and there was the same problem as with my one (i have programmed my based on this application)
    but both had the same problem they open on imageadd, but if i take more images in seconds (i think the script is still running => it can't recognize new images) it does not recognize the newly taken images.
    and i hope some script that imports all images in the folder will solve the problem.
    the more ore less only problem is to tell the application which images to import (like: on run import ALL files)

  • How do I get my NYTimes app off the new "Newsstand" and back into the folder I set up for all my news apps?

    I finally uploaded the now operating system 5.0 and set up iCloud. It rearranged all my apps on my iPhone, and took my NYTimes app out of the folder I set up for all my news apps and now I can't get it out. Nor can I move my other news apps onto the newsstand. Any ideas?

    You can't (at the moment).  Have been playing around with the same problem for about an hour - very irritating!!!
    If enough of us complain, (to the NYTimes) they might have it switched back, but I doubt it.  From the marketing point of view I would imagine they want "Newstand" to be THE subscription center, which does make sense.

  • Read all Files from a Folder on Server

    Hi,
    Can anyone help me in finding if there's any way to read all files in a folder on the server?Any Function module or anything.
    Thanks

    On App server?  Try this sample program.
    report zrich_0001 .
    data: begin of itab occurs 0,
          rec(1000) type c,
          end of itab.
    data: wa(1000) type c.
    data: p_file type localfile.
    data: ifile type table of  salfldir with header line.
    parameters: p_path type salfile-longname
                        default '/usr/sap/TST/DVEBMGS01/data/'.
    call function 'RZL_READ_DIR_LOCAL'
         exporting
              name           = p_path
         tables
              file_tbl       = ifile
         exceptions
              argument_error = 1
              not_found      = 2
              others         = 3.
    loop at ifile.
      format hotspot on.
      write:/ ifile-name.
      hide ifile-name.
      format hotspot off.
    endloop.
    at line-selection.
      concatenate p_path ifile-name into p_file.
      clear itab.  refresh itab.
      open dataset p_file for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset p_file into wa.
          if sy-subrc <> 0.
            exit.
          endif.
          itab-rec = wa.
          append itab.
        enddo.
      endif.
      close dataset p_file.
      loop at itab.
        write:/ itab.
      endloop.
    Regards,
    Rich Heilman

  • An error on a site deleted a photobucket folder full of pictures for a class and I'm trying to see if since I last veiwed them with firefox theres a way to recover them-With the cache or something?

    == Issue
    ==
    I have another kind of problem with Firefox
    == Description
    ==
    An error on a site deleted a photobucket folder full of pictures for a class and I'm trying to see if since I last veiwed them with firefox there is a way to recover them-With the cache or something?
    == This happened
    ==
    Just once or twice
    == I was on photobucket around 6pm on Mon July 19th
    ==
    == Firefox version
    ==
    3.5.9
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9
    == Plugins installed
    ==
    *-The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
    *Shockwave Flash 10.0 r42
    *My Web Search Plugin Stub for 32-bit Windows
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape
    *DivX Web Player version 1.4.3.4
    *npdnu
    *Office Plugin for Netscape Navigator
    *iTunes Detector Plug-in
    *GEPlugin
    *4.0.50524.0
    *MSN® Toolbar
    *Google Updater pluginhttp://pack.google.com/
    *RealJukebox Netscape Plugin
    *RealPlayer(tm) LiveConnect-Enabled Plug-In
    *6.0.12.69
    *Google Update
    *Java Plug-in 1.4.2_03 for Netscape Navigator (DLL Helper)

    Hi- I'm Sarie and no this didn't help. I actually tried to log in to respond and it said I wasn't registered. Not really all that cool.

  • Just updated to itunes 12.1.0.71 - big problem - can no longer access the legacy "Get Info" where you could change multiple files, easily add artwork, add album name for TV show, and much more. In previous iTunes 12 you'd right click

    Just updated to itunes 12.1.0.71 - big problem - can no longer access the legacy "Get Info" where you could change multiple files, easily add artwork, add album name for TV show, and much more. In previous iTunes 12 you'd right click and hold shift key and be able to get to it. Anyone figured this out?

    The "legacy" metadata editors, for which there was a "back door" in iTunes 12.0, have gone from 12.1.  However, the revised editors in 12.1 provide access to (almost) all the metadata elements that were available in iTunes 11, albeit in a different layout and with some additional constraints based on media kind.  Some users have / will have an issue with the statement that "Get Info has been completely redesigned in iTunes 12 to focus your attention only on what’s necessary for the selected item" since that removes some metadata elements that people may have been using in creative ways.  iTunes 12.1 basically gives you access to the fields that Apple think are necessary ... .  Some of the things that have been excluded by this rule:
    track and disc number fields for video media kinds
    show and episode fields for music
    description tab for audiobooks made up of more than one file
    Obviously the first two examples can be regarded as "overloading" the metadata elements - i.e., using them in ways that the designers didn't intend - but given that some users do find valid cases for this it's a shame that they've been deprecated in the new UI.  There are couple of workarounds:
    in songs view (or any of the other columnar views), you can still select any fields to display, independent of media kind, and these can be edited (though only one at a time) by double-clicking in the relevant "cell"
    you can (temporarily) change the media kind of an item (or group of items) to get access to metadata elements that would otherwise be inaccessible.
    It may be worth submitting an issue via https://www.apple.com/feedback/itunesapp.html - I can't see it as a huge development task to have a user preference to switch between "show all fields" and "filter fields based on media kind".
    One other oddity/irritation is that some of the tabs don't, by default, show all the available fields - you need to scroll up/down to access them or to expand the window by dragging on one of its corners.  Fortunately, the latter seems to be persistent - once you've done this to make all the fields visible the editor will open at the same (larger) size when opened again.

Maybe you are looking for

  • Playlists for syncing no longer exist?!

    so yesterday i had an urge to finally download the newest version of itunes. everything went smoothly until it was complete. i noticed that all my songs on my ipod got deleted. when i tried to sync all my songs again, a message popped up: "Songs on t

  • Mac Book Pro - SATA vs FW800 external drives

    I am pruchasing a MBP this week for road editing and I have a few storage questions for those in the know. In the past I have always blindly trusted a single external FW drive to capture, store and edit my projects. Since these jobs would be 5-10 day

  • SDM not starting up in SAP MMC

    Hi There, I have PI7 installed on win 2003 server with MS Sql server database. Since yesterday after I rebooted the system for some reason my SDM server is not running. I can see its status "stopped" in SAP MMC. Even i am forcely restarting it but it

  • Reinstall an app from the app store...

    Any ideas on how to reinstall an app from the app store. Tried the listed hold option, etc to avail...

  • Transportation of objects.

    Hi All, when we use  the  Transport connection  from RSA1 to transport the objects?But normally we go to SE09 or  SE10 Tr code to  release the task and then release the request to transport the objects from Dev system to QA system. which is most pref