I use OI file manager, but I would like to know if there is a way to remove spaces from file names and replace them with underscores, preferably in batch mode?

I would even be willing to perform this operation on my windows laptop, so this isn't specifically an Android question, though I'd prefer to do this on my phone. I'm a graphic artist and I have thousands of inconsistently named images in various places, and I'd really like to avoid doing this manually, one by one, as it would take months!

  • 1
    You may want to look at this question on StackOverflow; you can do this on Windows with a simple batch. Alternatively, there are a lot of bulk rename programs for Windows.
    – dotVezz
    Commented Dec 10, 2013 at 17:46

1 Answer 1


This is certainly possible with , though I cannot give you the "complete recipe". Basically, you could create a task like this:

  • Execute Command: ls -1 /path/to/your/files, and capture the output into a variable
    the command will list all files in the given directory, one file per line
  • Work on the variable. There are possibilities to convert it into an array, so you can use a for loop to handle each file
  • again with variables, you can setup the rename command (e.g. using Variable Search Replace) in a new variable. Pseudo-Code: mv "$old_name" "$(s/ /_/,$old_name)"

But it is much easier to use a simple shell script in some terminal app (or via adb shell) to achieve the same:

cd /path/to/your/files
for file in $(ls -1); do mv "$file" "$(echo $file|sed 's/ /_/g')"; done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .