Search Unity

Find and replace bunch of filenames

Discussion in 'General Discussion' started by BIGTIMEMASTER, Jan 15, 2020.

  1. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    edit: for purpose of unity terrains, you don't need to rename from .r16. just switch file search dropdown to all files and you can import the .r16 and it will work.

    Windows explorer doesn't have any find and replace function. I have hundreds of .r16 files need to change to .raw.

    I think I can use this code here in powershell:
    Dir | Rename-Item -NewName {$_.name -replace "Mustang","Appaloosa"}

    but I don't know how to implement it for my purpose. In my case, i need to find "r16" and replace with "raw"

    Otherwise, you guys know some tools I could use, either in windows or maybe inside unity?

    Thank you!
     
    Last edited: Apr 19, 2020
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    C# and the System.IO namespace can do this. If you need something quick and dirty you can just run it from a Unity script.
     
    BIGTIMEMASTER likes this.
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I think this is one I've used in the past, but as with any free software be careful what you install. The UI is cluttered as all heck, but just enable the one bit you need and it's ok.
     
    BIGTIMEMASTER likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    Try use TotalCommander for such things. In past was called Windowscomander, but name changed years ago, because of naming conflict with M$, Is free to use for none commercial applications.
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,573
    You can use C#, like suggested by boredmo... I mean Kiwasi, or you could cook up a python script.

    If you're familiar with unix/linux, you can install mingw or msys, and use unix tools for that.

    Additionally, if you don't want to script, you can use "orthodox file manager" like FarManager, TotalCommander and so on. In FAR, renaming a few million of files is a matter of few keypresses. You just select target folder, and specify that you want *.raw as a filename. It'll rename it by default.

    Far Manager is available for free under opensource license.
    https://en.wikipedia.org/wiki/Far_Manager

    Using FAR will be probably fastest.
     
    Kiwasi and BIGTIMEMASTER like this.
  6. XCPU

    XCPU

    Joined:
    Nov 5, 2017
    Posts:
    145
    a simple command prompt should do the trick though. ren *.r16 *.raw
     
  7. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Indeed.^
    If you need a little more complexity, you just write shell script. If you need complexity you can use Ruby/Python/AS and write some to run in the shell. If is something you use a lot, save the script and stick a shortcut to it in your bash profile.
     
    iamthwee and BIGTIMEMASTER like this.
  8. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    I tried using command but I couldn't figure out how to navigate to the right folder. By default command is starting from my SSD, but I was needing to get at a folder on harddrive. Just typing or copy/paste in the directory wasn't working. Scripting makes no sense to me. Anyway, I did the same thing but through powershell, because you can open powershell directly from explorer and it goes to the right place. Here's what I did:
    https://www.windowscentral.com/how-...bulk-windows-10#rename-files-using-powershell

    I wouldn't have known to even look if not for advices here. Thanks everybody! Save me a lot of trouble.
     
  9. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,573
    you type a letter of desired hard drive. "c:"
    Then navigate where you need using cd command. "cd .." goes up. "cd <foldername>" goes down folder. "dir" lists contents of current folder.
     
    Kiwasi likes this.
  10. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    upload_2020-1-18_18-22-20.png

    How do I get rid of this default directory?
     
  11. Deleted User

    Deleted User

    Guest

    Examples here: https://www.howtogeek.com/111859/ho...s-in-windows-4-ways-to-rename-multiple-files/

    Scroll down to "Since the ren command can address extensions, you can also use it to change the extensions of multiple files at once. Say, for example, you had a selection of .txt files that you wanted to turn into .html files. You ..."
     
  12. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,573
    Wrong syntax.
    Command line accepts "command" followed by parameters separated by spaces. If parameters hold spaces, they can be enclosed into quotes.
    There's no command "c", however you can type "c:" (with semicolon), which will be a different thing.

    In your example, you're already on drive C, so you don't need to type letters.

    Instead you type "cd .."(followed by enter) to go up, "cd <foldername>" to go down, "dir"(followed by enter) to list contents and so on.

    That's just basics.