Author Topic: Windows Scripts for Adding & Removing Spaces in Filenames?  (Read 1033 times)

Offline Baby Naruto

  • Member
  • Posts: 323
  • Playful Explorer
    • My DeviantART Profile
Does anyone know where I can download scripts for "Windows XP" that can add and remove spaces in filenames?

Note: I do not want scripts that replaces spaces with underscores, periods etc, I just want scripts that can add spaces to file names, and also remove them.

Offline Freedom Kira

  • Member
  • Posts: 4324
  • Rawr™.
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #1 on: May 15, 2011, 04:21:31 AM »
You're gonna have to be more specific. I would assume that you want one that replaces spaces with underscores or vice versa. Your note kinda throws that out the window without really specifying exactly what it is that you're looking for.

In case you're looking for a script that pads spaces on the end of a filename, you can't do that. AFAIK filenames are trimmed of those spaces automatically.

Offline Baby Naruto

  • Member
  • Posts: 323
  • Playful Explorer
    • My DeviantART Profile
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #2 on: May 15, 2011, 04:47:14 AM »
You're gonna have to be more specific. I would assume that you want one that replaces spaces with underscores or vice versa. Your note kinda throws that out the window without really specifying exactly what it is that you're looking for.

In case you're looking for a script that pads spaces on the end of a filename, you can't do that. AFAIK filenames are trimmed of those spaces automatically.

To put it simply......

I want Naruto Rocks.jpg to become NarutoRocks.jpg, without me having to manually remove the space between Naruto and Rocks, etc.

Offline billlanam

  • Member
  • Posts: 316
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #3 on: May 15, 2011, 05:33:26 AM »
You're gonna have to be more specific. I would assume that you want one that replaces spaces with underscores or vice versa. Your note kinda throws that out the window without really specifying exactly what it is that you're looking for.

In case you're looking for a script that pads spaces on the end of a filename, you can't do that. AFAIK filenames are trimmed of those spaces automatically.

To put it simply......

I want Naruto Rocks.jpg to become NarutoRocks.jpg, without me having to manually remove the space between Naruto and Rocks, etc.

Removing spaces is easy, adding will only work if you have a consistent way to determine where they go, which is very unlikely, easier to make a hard link of the file name without spaces in another folder, then you still have the original names.

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #4 on: May 15, 2011, 05:50:44 AM »
Does the script have to run without any additional installations? It would be trivial in perl, although like the others said, you would need to have a consistent way to determine where to add spaces back in. Something like "after before every capital letter" would work fairly well.
Until you hit abbreviations.

Of course, there's still the issue of name clashes: since a rename is essentially a move, some files might "magically" disappear on you if you rename "A B C" to "ABC" when "ABC" already exists. <<Had similar happen.

Is there a specific reason you don't want underscore replacement? It's fully reversible, and the names wouldn't be escaped in URLs/etc. because of it. Obviously if it's personal preference there's nothing for it, but I was wondering if maybe the concern was something that could be alternately addressed.
« Last Edit: May 15, 2011, 06:21:17 AM by ph4zr »
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Teaparty

  • Member
  • Posts: 289
  • Where am I?
    • Riceballicious
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #5 on: May 15, 2011, 06:02:32 AM »
Do you want this script for learning reasons? If you just want file names modified, you can find many batch-rename softwares online.
« Last Edit: May 15, 2011, 06:06:56 AM by Teaparty »

Offline kureshii

  • Former Staff
  • Member
  • Posts: 4485
  • May typeset edited light novels if asked nicely.
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #6 on: May 15, 2011, 08:15:02 AM »
Bulk Rename Utility. A little more involved than a script, but you should be able to do plenty more with it.

Offline Baby Naruto

  • Member
  • Posts: 323
  • Playful Explorer
    • My DeviantART Profile
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #7 on: May 15, 2011, 05:42:20 PM »
Honestly, I have files with too many spaces after I remove the underscores and replace them with spaces.

Like I have this file Aren't_You___A_Cutey.jpg

After I use my vbs script that replaces underscores with spaces, it becomes Aren't You   A Cutey.jpg

I want a script that can remove all of those extra spaces between You and A, but it leaves one space in/alone.

(I have 900 other pictures/images that are in the exact same situation as that one)
« Last Edit: May 15, 2011, 05:43:56 PM by Baby Naruto »

Online Duki3003

  • Admin
  • Member
  • Posts: 4420
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #8 on: May 15, 2011, 06:52:54 PM »
Bulk Rename Utility. A little more involved than a script, but you should be able to do plenty more with it.

^ this. It can do what you want and more...

Offline Baby Naruto

  • Member
  • Posts: 323
  • Playful Explorer
    • My DeviantART Profile
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #9 on: May 15, 2011, 08:36:15 PM »
Thanks for the help everyone :), problem solved :D.

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #10 on: May 15, 2011, 11:34:40 PM »
I want a script that can remove all of those extra spaces between You and A, but it leaves one space in/alone.
Makes sense. Grats on solving the problem. But, one last thought: you could also just collapse multiple spaces/underscores into a single one, this way you don't lose the meaning of such word breaks.
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline bork

  • Member
  • Posts: 251
  • Huh ?
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #11 on: May 16, 2011, 02:37:54 AM »
I know the original question was for a Windows script but if anyone is interested in a Unix/Linux flavor:

(click to show/hide)
« Last Edit: May 16, 2011, 02:44:53 AM by bork »

Offline rkruger

  • Member
  • Posts: 124
  • #include <bakabt.h>
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #12 on: May 16, 2011, 06:38:29 AM »
I know the original question was for a Windows script but if anyone is interested in a Unix/Linux flavor:

(click to show/hide)

For people wanting to learn more, let me complement that with a bash one-liner that performs the same task:
Code: [Select]
shopt -s extglob; for i in *; do mv -i "$i" "${i//+( )/ }"; done

Offline Pants

  • Member
  • Posts: 119
  • Pants are superior.
    • Tracker Profile
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #13 on: May 20, 2011, 08:05:09 AM »

I love this thing, have used it for years, and nothing I could ever say could embody how awesome it is. No installs - it just runs and works. Sure, it isn't very pretty, but it's a hell of a workhorse.
When you spam, you go all out don't you? God bless the select all and delete selected button... ~Duki3003

Offline bork

  • Member
  • Posts: 251
  • Huh ?
Re: Windows Scripts for Adding & Removing Spaces in Filenames?
« Reply #14 on: May 20, 2011, 09:16:00 PM »
shopt -s extglob; for i in *; do ln -i "$i" "${i//+( )/ }"; done

Have the best of both now.   ;D