-1

How can I remove the special character using DOS Command on folder and subfolders?

Folders:

C:\FILE\FOLDER#1\PICTURE#100

C:\FILE\FOLDER#2\PICTURE#200

C:\FILE\FOLDER#3\PICTURE#300

C:\FILE\FOLDER#4\PICTURE#400

C:\FILE\FOLDER#5\PICTURE#500

OUTPUT:

C:\FILE\FOLDER1\PICTURE100

C:\FILE\FOLDER2\PICTURE200

C:\FILE\FOLDER3\PICTURE300

C:\FILE\FOLDER4\PICTURE400

C:\FILE\FOLDER5\PICTURE500

Thanks

Imane Fateh
  • 2,418
  • 3
  • 19
  • 23
  • Are you actually using an old version of MS-DOS (in that case, which version?) or the command prompt in Windows? The "#" isn't a special character in ``cmd`` so you can just rename each file or folder at a time using ``ren `` Or are you asking how to automate that process for all files and folders? – acfrancis Oct 21 '13 at 11:25
  • 1
    The folder names are more than 8 characters long - must be Windows. – foxidrive Oct 21 '13 at 11:27
  • im using Windows 7 Command Prompt. i just want to remove this character "#" to all folders and sub-folders. – HelpLessDumb Oct 21 '13 at 11:43

2 Answers2

1

Try this on some sample folders first. It will rename two levels of folders.

@echo off
setlocal enabledelayedexpansion
pushd "c:\file"
for /d %%z in (*) do (
  pushd "%%z"
     for /d %%a in (*) do (
         set "folder=%%a"
         ren "%%a" "!folder:#=!"
     )
  popd
)    
for /d %%a in (*) do (
     set "folder=%%a"
     ren "%%a" "!folder:#=!"
)
popd
foxidrive
  • 40,353
  • 10
  • 53
  • 68
0

using renamer:

$ renamer --find "#" **

Removes the "#" from all files and folders recursively

Lloyd
  • 8,204
  • 2
  • 38
  • 53