Renaming many files

How would I rename many files (over 100 total) in a directory using
a UNIX command or script.
Example of my files:
file1.word.1.word
file2,word,2
file3 word.3
I want them to be named:
File1_word_1_word
File2_word_2
File3_word_3
My goal is to get rid of blanks,commas and periods and replace with underline bars for each file name.

Hi:
I had a lot of fun wrting this script. Hope you find it useful.
Copy the following to a file name
#!/bin/csh
if(-d $1) then
cd $1
foreach i (*)
set ii = `echo $i | sed s/\\\./_/g | sed s/\,/_/g | sed s/\ /_/g`
mv "$i" $ii
end
else
echo "USAGE: $0 directory"
endif
give permission to execute. Run it with the directory name as an argument. May be you can refine it further.
It was fun! hope it helped.
Angelo
Sun Developer Support.

Similar Messages

  • How can I rename many files at the same time?

    Hello!
    I have a bunch of PDF files (2 thousand at least) that I need to transfer to another Mac but since it's running OS 9.2 it won't accept the files because the names are too long, therefore, I need a quick way to change all such files into a shorter name but maintaining some of the serial numbers each file name has (i.e., not changing all to the same name but just taking off the first or last 5 characters for example), is there a way to do this sort of thing with OS 10.3.9 or 10.5.2?
    Best!
    Danny

    Look at this shareware. http://www.jonn8.com/ntf/ It's a batch renaming app, but I'm not sure it will do exactly what you want. However, it does have a 7 day free trial.
    If you do a Google serach using +batch file rename mac+ you can review a lot more apps.
     Cheers, Tom

  • Infopackage-Load Many Files from Application Server and later Archive/Move

    Hi All..
      I have a doubt,   I have a requirement of take many files to load into BI 7.0..  I used the infopackage before with option:
    Load Binary File From Application server
      I load information successfully... only with one file ...but If I can load many files (with different names) like the next list.. I think it's not a good idea modify the file name (path) on infopackage each time).. :
    *All of this files will be on one server that itu2019s map into AL11.. Like
    Infopfw
    BW_LOAD_20090120.txt
    BW_LOAD_20090125.txt
    BW_LOAD_OTHER_1.txt
    u2026.
    Etc..
    This directory it's not in BW server.. It's other server..but I can load form this location (one file by one)
    Could you help me with this questions:
    -     How can I Use an infopackage with routine that take all the files..one by oneu2026 in order of creation dateu2026and load into Target? Is it possible?.. I have some knowledge of ABAP.. but I don´t know exactly how I can say to system this logicu2026
    -     In addition is it possible move this files to other locationu2026 like into Infopfwarchive u2026 just to have an history of files loaded.
    I saw that in infopackage you have an option to create a routine.. in ABAP codeu2026 Iu2019m a little bit confused because I donu2019t  know how I can specify all the path..
    I try with:
    Infopfw
    InfopfwFile.csv
    Infopfw
    This is the abap code that automatically you see and you need to modifyu2026
    Create a routine for file name
    This routine will be called by the adapter,
    when the infopackage is executed.
              p_filename =
              p_subrc = 0.
    Thank you for your ideas or recommendations.
    Al

    Hi Reddy, thank you for your answer
    I have some doubuts.. when you explain me the option:
    All the above files are appending dates at the end of the file....
    You can load the files through infopackage by using Routines and pick the files based on date at the end of the file..***
    I need to ask you if you think that when you know the date of the file and the infopackage pick each file... thi can work for many files??... or how it's possible control this process?
    About this option, I want to ask you If when you menction Unix code... where it's programed this code?.. in the routine of BW Infopackage??
    ****Or
    Create two folders in your BW in Application server level, in AL11 (ask Basis team)
    I call it is F1 and F2 folders.
    First dump the files into F1 I assume that the file name in F1 is "BW_LOAD_20090120.txt", using Unix code you rename the file and then keep in the same foleder F1 or move to F2.
    Then create InfoPackage and fix the file name (i.e. you renamed), so you don't need to change everyday your file name at infopackage level.Because in AL11 everyday the file are overwrite.
    To I get BW_LOAD_20090120.txt file in F1, then I renamed to BW_LOAD.txt and loaded into BW, then tomorrow I get BW_LOAD_20090125.txt in F1, then I renamed to BW_LOAD.txt....
    so in this way it will work.You need to schedule the Ubix script in AL11.
    This is the way how to handle the application server...I'm using the same logic.
    Thank you soo much.
    Al

  • How do I rename many photos all at one time with one click?

    I have got many photos of a sery and want to rename it all with one click only (instead of clicking through it all in single actions and wasting time).
    How can I rename many pictures/photos all together with one click only? -
    1) I have OS X Yosemite
    2) Aperture
    3) Automator App
    to use for this purpose, but I do not see through with any of it.
    Detailed Support for 1) and 2) and 3)  please!
    jona li

    Here is an article on how to batch rename files in Yosemite using just the Finder. This is a new feature in Yosemite. See if this article helps you get your files renamed.

  • After renaming a file extention from .jpeg to .jpg I can no longer type ...

    After renaming a file extention from .jpeg to .jpg I can no longer type in any of the finder related editable fields/boxes. I can still type in my open applications fields.
    This problem also happens when I happen to find a file that has been named, for instance, 2008jpg. When I add the period to have the file read correctly as 2008.jpg, a warning box appears asking - {*Are you sure you want to change the extention from ".jpeg" to ".jpg"?* If you make this change, your document may open in a different application.} Two radio buttons are available within this warning box that read - 1 - {Use .jpg}(it is not color coded, which means it must be selected manually. - 2 - {Keep .jpeg}(it is colored w/my Blue highlight color, which means it will be selected if the Enter Key is used.
    The warning box does Not appear if I remove the period from a file and not again when i re-add the period to that same file.
    After trying to make these types of edits to the name of any file, with any of the various extentions available for files in our digital world, I usually get an anomaly where myability to type in the Finder ceases to be a possibility.
    I have found that I can Force Quit the Finder for a quick fix, but, I'm not sure that this Typing problem should have to be dealt with at all by this quick fix. Is this an issue with the Indexing in Spotlight, which seems to be giving many users problems?

    I downloaded and tried EasyFind. It works but it took 30+ seconds to complete finding 3 files that are on One of my Five 25+ Gb partitions of my 130 Gb Seagate Cuda(Really 160 Gb, but my Sawtooth will only recognize 130) I figured that if I ever got a better box, I could reformat it to see the whole 160 Gb. So, as far as I can see, Spotlight's indexing scheme which finds the files instantly is probably preferable. Spot light allows you to rename your files from within it's app window. I've always thought that was pretty powerful. Could my doing so be causing me any issues? As i said it is the inability to Type in the Finder that seemed to be caused from changing file Extentions that were mis-written. Maybe it was a delayed reaction to my renaming files in the Spotlight app? I've done both on occasion.
    As for these .DS_Store files. Apparently you can NOT stop them from being written to any folder that you touch/open/view during a days session. But, as a function of the OS, are the essential to have in their respective folders Forever? I've looked at the .DS_Store terminator app briefly and assume that getting rid of these files won't hurt the regular operation of my OS. They will just be re-written if I ever have to go back to any particular folder again. But, apparently, some have said that if the plan on burning a CD or DVD of their data, they delete the .DS_Store files first and then do the burn.
    I'm thinking from your having suggested this tremination app that you suspect that my having all of these ,DS_Store files could be a situation where any of them could have become corrupted and terminating them regularly should be part of my regular maintenance.
    Does that sound like I'm understanding what I can do?
    TIA

  • Help renaming pdf files based on internal content

    I work for a company that has thousands of E-tickets coming in daily, weekly, monthly, etc..
    These tickets come in bafhakfbaifh.pdf and we have to manually rename them or print them all out and then sort through them and put them in order.
    What I would like to do is:
    1. Split any pdf's that have more than one page or "ticket" in my case. I know how to do this with automator easily, but I'd love to keep it all in one program.
    2. Search the file for Event Name (i.e. Madonna)
    3. Search the file for Date of event (August 12, 2012)
    4. Search the file for Section, Row, Seat (124 3 12)
    5. Rename the file based on content found (Madonna August 12 2012 124 3 12.pdf)
    6. Move from original download folder to organized folders based on artist/team.
    7. Automatically print in alphabetical or some sort of designated order.
    Any help is muchly appreciated. So far, I found a PC program called A-PDF rename, but it is not automated enough to be practical. Hazel is awesome at OCRing the pdf and moving from folder to folder, but does not do enough.
    Any help is muchly appreciated.
    Thank you.

    You're looking for a PDF Parser or PDF miner tool (PDFminer) as a starting framework, and you'll almost certainly be writing custom code around that as parsing a text file that's effectively free-form and originating from multiple different sources almost always (always?) involves writing customized processing code and an on-going series of tweaks as the suppliers of the PDF change their ticket formats.  (Even apparently-simple details such as the time and date formats, for instance, can vary by geography and language and by supplier, and can derail common processing.)
    In some cases that I can envision, it'd be entirely possible that the data you're after is actually located in an embedded image and not in text that can be parsed.
    The best approach is to get folks to send you JSON or XML or some other format intended for interchange, and avoid the whole mess that is parsing or mining a printer-oriented format.
    The other obvious option is to use something like Amazon's Mechanical Turk or some other explicitly outsourced help.  Depending on how often the formats change and how many of these PDF files you're dealing with and how varied the formats are, sometimes throwing staff at the problem can be the most cost-effective approach.

  • Where are the actual files/renaming those files?

    Hi all, I'm a new Mac user at home, and I'm exploring how iPhoto works. Since 1999, I've kept my digital photos straight using a manual method of folders labeled "Year" and inside that "01, 02, etc" and inside that "01 PhotoName" for something that happened on the 1st day of the month (following me?) With iPhoto, I gather this is much easier to manage because iPhoto seems to do all of this for me.
    I'm trying to understand how iPhoto is working. It seems that when I import a photo from my camera, it goes to a folder in "iphoto library"/originals/2007/album name/photoname (in my case, the file name is DSC02447). However, if I make any changes to that file within iPhoto (red eye, color, etc) it will create ANOTHER file in "iphoto library"/MODIFIED/2007/albumname/photoname. So, does that mean it's essentially duplicating my images?
    Also related, how can I rename the actual FILE? When I'm within iPhoto's Photo view, I can rename the title of the image by clicking the name below it, and renaming it to something other than DSC02447. However, in the "photo info" window, you can see the actual filename has NOT changed.
    If I would use iPhoto forever, that wouldn't be a big problem. However, I don't know what photo organizing program I'll be using in 10 years, but if it's not iPhoto, I don't want to be stuck with a whole lot of photos that I spent a bunch of time organizing and renaming within iPhoto, only to realize those changes were only within iPhoto.
    So along with those two questions, does anyone have a website that explains the "inner workings" of iPhoto better than the Apple site? All I can find on here is "here's all the great things iPhoto does" but I can't really find deep tutorials on "this is actually what's happening to your files."
    Many, many thanks everyone.

    Carl
    I'm trying to understand how iPhoto is working. It seems that when I import a photo from my camera, it goes to a folder in "iphoto library"/originals/2007/album name/photoname (in my case, the file name is DSC02447). However, if I make any changes to that file within iPhoto (red eye, color, etc) it will create ANOTHER file in "iphoto library"/MODIFIED/2007/albumname/photoname. So, does that mean it's essentially duplicating my images?
    Duplicating? No, but it is preserving your original file - as a kind of digital negative. Essentially, all operations are carried out on a copy of the file, at any time you can go Photos -> revert to original. In this iPhoto is implementing the best practise of Digital Asset Management.
    If you don't wan that feature, then bluntly, don't use iPhoto. It's hard wired into the application and cannot be turned off. There are various hacks that claim to remove unwanted versions but each of them put the integrity of your library at risk.
    It is strongly advised that you do not move, change or in anyway alter things in the iPhoto Library Folder as this can cause the application to fail and even lead to data loss
    Also related, how can I rename the actual FILE? When I'm within iPhoto's Photo view, I can rename the title of the image by clicking the name below it, and renaming it to something other than DSC02447. However, in the "photo info" window, you can see the actual filename has NOT changed.
    You can't. You can copy the files to the desktop and rename them before import (FileList is pretty good for this) or, if you export them using the File -> Export command you have the opportunity to use your Title as a filename on the exported version. (That's your future proofing, right there - you can also write you keywords to the file too.) But if you rename the files while they are in iPhoto, then you change the path to the files and that brings you to my warning above, about making changes in the iPhoto Library Folder.
    So along with those two questions, does anyone have a website that explains the "inner workings" of iPhoto better than the Apple site? All I can find on here is "here's all the great things iPhoto does" but I can't really find deep tutorials on "this is actually what's happening to your files."
    Here?
    Regards
    TD

  • How can i bulk rename music files in reverse order from artist - song name to songname - artist

    How can I bulk rename music files in reverse order from artist - song name to songname - artist.
    I actually dont need to rename the actual files.
    Its just i have a huge txt list of 100,000 music names that are listed as so..
    Artist - Song Name
    Artist - Song Name
    Artist - Song Name
    Artist - Song Name
    Artist - Song Name
    Artist - Song Name
    and i need this list to reverse it self so it is listed in the list as
    Song Name - Artist
    Song Name - Artist
    Song Name - Artist
    Song Name - Artist
    Song Name - Artist
    Song Name - Artist
    Song Name - Artist
    Im sure there is some kinda way to auto a mix of applescript/automator/terminal to do something like:  all char before the "-" replace with the chars after the "-".
    Please some one help me if you know how I can pull this off

    How can I bulk rename music files in reverse order from artist - song name to songname - artist.
    I actually dont need to rename the actual files.
    Its just i have a huge txt list of 100,000 music names that are listed as so.
    I wonder if we haven't misunderstood what you were asking for. Could it be that you have not a huge file, but just a huge list of names in many small files. If that's the case, you should rather use the following script instead of the previous one.
    Since this script does not rename the files, make a backup of your files before running it.
    set theFolder to choose folder -- the folder containing your text files
    tell application "Finder"
        set theNames to name of files of theFolder whose name extension is "txt"
    end tell
    set theTextFiles to {}
    set theFolderPath to POSIX path of theFolder
    repeat with thisName in theNames
        copy theFolderPath & thisName to the end of theTextFiles
    end repeat
    repeat with thisFile in theTextFiles
        set F1 to open for access thisFile
        set theText to read F1
        close access F1
        set theParagraphs to paragraphs of theText
        set bigList to (a reference to theParagraphs)
        set theNewParagraphs to {}
        set bigNewList to (a reference to theNewParagraphs)
        repeat with X in bigList
            set P to offset of " - " in X
            if P = 0 then
                set Y to X
            else
                set Y to text (P + 3) through -1 of X & " - " & text 1 through (P - 1) of X
            end if
            copy Y & return to the end of bigNewList
        end repeat
        set theNewText to text 1 through -2 of (bigNewList as text)
        set F2 to open for access thisFile with write permission
        set eof F2 to 0
        write theNewText to F2
        close access F2
    end repeat
    display dialog "Done!" buttons {"OK"} default button 1 with icon 1
    Message was edited by: Pierre L.

  • Renaming .mov files

    I am using FCP 6.0.6. I need to rename many of the .mov files used in my FCP projects. Will I be able to reconnect them once, or will I need to reconnect the media everytime? What else should I be on the look out for?
    Alternatively, I have a back up hard drive with all the files organized. Can I use that hard drive with the FCP sequences I've built using another hard drive? Will it be able to match sequences based on duration?
    Thanks.

    You would be hard pressed to be able to reconnect them at all.  Unless you remembered the original names of every file, and reconnected one at a time. This is a BAD idea.  You rename BEFORE you edit.  If you rename, you reimport into the project...don't do it after you started editing. Bad bad bad bad...

  • Bulk rename of files in subfolders

    Hello All
    I have a folder containing 40 subfolders, and inside each of these subfolders are a number of files (between 4 and 45 each) totalling over 500 files.
    Each filename starts with a string "orginalstring".
    What I would like is the easiest way (whether using Automator or not) to replace all 500+ "orginalstring" with "replacementstring".
    Many thanks for your help. Philip

    Although the original poster's problem is long solved and it doesn't directly help.  Here is an appleapplescript that will perform a batch rename of selected files with ne names provided in a .csv file.  SImply open applescript, paste in an run.  Its not the most robust - it will fail if you try to create duplicate files, but for the most part it does a good job for a quick and dirty.... Beanlander
    -- Bulk Rename files from .csv file
    on run {}
        set file_NewFilenames to choose file with prompt "Choose .csv file containing new filenames"
        set files_ToBeRenamed to choose file with prompt "Choose files to be renamed" with multiple selections allowed
        set filedata_NewFilenames to read file_NewFilenames
        set list_NewFilenames to paragraphs of filedata_NewFilenames
        -- determine the maximum number of files that can be renamed
        set num_MaxFilesToRename to count of list_NewFilenames
        if num_MaxFilesToRename > (count of files_ToBeRenamed) then
            set num_MaxFilesToRename to count of files_ToBeRenamed
        end if
        --display dialog "Renaming " & num_MaxFilesToRename & " files…"
        repeat with i from 1 to num_MaxFilesToRename
            try
                set fileToBeRenamed to item i of files_ToBeRenamed
                set newName to item i of list_NewFilenames
                set AppleScript's text item delimiters to "\""
                set newName to (text items of newName)
                set AppleScript's text item delimiters to ""
                set newName to (newName as string)
                --display dialog newName as text
                tell application "Finder"
                    set filenameExtension to name extension of fileToBeRenamed
                    set name of fileToBeRenamed to newName & "." & filenameExtension
                end tell
            on error
                display dialog "Could not rename: " & fileToBeRenamed giving up after 3
            end try
        end repeat
    end run

  • Batch renaming m2t files

    I wonder if there is a way to rename m2t files captured from a CF card, either in the log&capture window or directly after that, in the browser? Now I have different cards with the same file name beginning (e.g. 00_) and that makes it impossible to sort them logically in a bin, even when I chose recording time and date as a criterium.

    There are also many utilities that will rename files. Go to versiontracker.com and do some searching.

  • Renaming .PPTX files returns -108 and -43 error

    I've had this issue a year ago and it's now repeating.
    When I rename a .pptx file I sometimes get a -108 or -43 error. The file is then un-openable.
    The fix is to be able to rename the file.
    Last year when this was happening the files I was renaming were alway in a dropbox folder. So I presumed it was something to do with the dropbox application. The fix is this case was to rename the .pptx file from the dropbox website. - once renamed the file was nigh on immediately fixed.
    I took my MBP to an apple store as it's still under applecare and they wiped the drive and i had to re-install everything. it did how ever work. for a while.
    It's started happening again, again it's .pptx files in the dropbox folder - however it's also happened to files outside the dropbox.
    the fix I've found for hte files outside dropbox is openning up the pptx file via Windows XP in Parallels! n.b. all i need to do is open the PPTX file via PowerPoint running on Windows XP on my macbook.
    Looking online, some say -108 errors are memory issues (hard drive) - well i've got 250GB of free space. 8GB of RAM.
    anyone got any suggestions on a permenant fix ?
    many thanks for reading.
    JC

    Since it seems that it's primarily a MS Office problem that you're having (and you don't say which version of Office that you're using), I would head on over to the MS Office forums and ask there - http://answers.microsoft.com/en-us/mac/forum/.
    Good luck,
    Clinton

  • How to do search with multiple texts across documents and rename the file with found text?

    Hello:
    I'm trying to do the batch search across the multiple documents and rename the file (or save as) after the found word?
    In example:
    I have many unique texts and would want to search across the multiple documents.
    If a document is found with that unique text then, the document is either renamed or save as with that unique text. 
    So, I could know what unique text that file holds.
    How do I do that?
    Let me know.
    Thanks

    Welcome to the forum!
    When you want to post a block of code, you can enclose it with the mark ups { code }
    That is the key word code surrounded by curly brackets, but without the spaces
    You seem to be running a very old (and unsupported release of the database)
    7.3 has not been a current release for about 10 years.
    It's probably been that long since I've used this technique, but i think it should work.
    You should consider welcoming your system to the 21st century by upgrading to a supported release ;-)
    If you used split to chop up your export file, use cat or dd to reassemble it.
    So, something like this:
    mknod bk.dmp p
    cat xaa xab xac xad xae xaf xag xah xai > bk.dmp &
    imp SYSTEM/$PASSWD parfile=imp_bk.parfile
    rm bk.dmp
    $ cat imp_bk.parfile
    file=bk.dmp
    log=imp.log
    full=y
    buffer=1048576
    ignore=y
    commit=y let us know if still have problems.
    Good Luck!

  • Automatically renaming pdf files based on excel data

    I am creating pdf certificates using variable data from excel files with InDesign.  This creates a multipage pdf file with a different persons name on each page.  Then end result needs to be individual pdf files named for each person.  I can extract the single pages out of the main pdf ending up with however many files all named the same thing besides a number at the end of the common file name.  Question:  Is there a automated process of renaming the individual files using the data from the excel file?

    You're looking for a PDF Parser or PDF miner tool (PDFminer) as a starting framework, and you'll almost certainly be writing custom code around that as parsing a text file that's effectively free-form and originating from multiple different sources almost always (always?) involves writing customized processing code and an on-going series of tweaks as the suppliers of the PDF change their ticket formats.  (Even apparently-simple details such as the time and date formats, for instance, can vary by geography and language and by supplier, and can derail common processing.)
    In some cases that I can envision, it'd be entirely possible that the data you're after is actually located in an embedded image and not in text that can be parsed.
    The best approach is to get folks to send you JSON or XML or some other format intended for interchange, and avoid the whole mess that is parsing or mining a printer-oriented format.
    The other obvious option is to use something like Amazon's Mechanical Turk or some other explicitly outsourced help.  Depending on how often the formats change and how many of these PDF files you're dealing with and how varied the formats are, sometimes throwing staff at the problem can be the most cost-effective approach.

  • 8g touch updated 4.2.1, problems synching apps and music. gives multiple errors; device times out, internal device errors, network times out, duplicate file, too many files open. itunes diagnostics ok. what to do?

    have an 8g ipod touch which has had problems trying to play games and downloading update 4.2.1. went to the apple store who kindly downloaded the software update but now can't synch and generates multiple error messages; device times out, internal device error, network times out, duplicate file and too many files open etc etc. have latest i tunes download and diagnostic test ok. what can i do?

    Does the ext directory have the php_oci8.dll? In the original steps the PHP dir is renamed. In the given php.in the extension_dir looks like it has been updated correctly. Since PHP distributes php_oci8.dll by default I reckon there would be a very good chance that the problem was somewhere else. Since this is an old thread I don't think we'll get much value from speculation.
    -- cj

Maybe you are looking for