find firnames with invalid characters such as a % and re

January 16, 2017 at 16:59:53
Specs: Windows 7
I have filenames with % or _ or - in the filename. these will not sync to onedrive. How can I find these files and replace the % with a blank space.

See More: find firnames with invalid characters such as a % and re

Report •

#1
January 16, 2017 at 17:33:48

Report •

#2
January 30, 2017 at 02:42:05
Should be possible in batch, could you provide the path to the folder where these files are located? or is it %USERPROFILE%\OneDrive?

preview:

ftree
C:\Users\*****\etc
├123_5.txt
├1yh-ekbs.txt
├etfsf-hsejs_5.txt
└test%1.txt
for /f "tokens=1-9 delims=-_%" %a in ('dir /b ^| findstr ".txt"') do echo %a %b %c %d %e %f %g %h %i
123 5.txt
1yh ekbs.txt
etfsf hsejs 5.txt
test 1.txt

this command renames the files in mass for the current directory

@echo off&for /f "tokens=1-9 delims=-_%" %1 in ('dir /b ^| findstr ".txt"') do (for /f %a in ('dir /b ^| findstr ".txt"') do ren "%a" "%1 %2 %3 %4 %5 %6 %7 %8 %9")&exit /b

it does work, but im doing it the wrong way lel

this right now only works for .txt files, just change the ".txt" to for example ".docx" to do special files

the command contains 2X ''.txt"

Also i could make it fit what you need, if you could profide me a list of names of the files

Simple solutions are often the best

message edited by hidde663


Report •
Related Solutions


Ask Question