Removing certain characters of a certain file [closed] - windows

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to remove certain characters from multiple files which share the same extension. An example would be: filename = 01songname.mp3 to songname.mp3, but doing that command to all the mp3 files in the directory, not renaming to one name but removing the numbering.

Based on your existing examples this may work for you.
#echo off
FOR %%M IN (*.mp3) DO (
FOR /F "tokens=* delims=0123456789" %%G IN ("%%~M") DO ECHO RENAME "%%~M" "%%~G"
)
pause
Remove the word ECHO before the word RENAME if you feel the output on the screen looks correct.

Related

Script to list extensions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to write a windows batch script that lists all extensions in a directory, recursively.
The desired behaviour is this:
You start the bat file in directory "a" which contains the following files: b.txt, c.png, d.txt, e.jpeg, f.jpg.
The script should output the following:
txt
png
jpeg
jpg
I would like the each extension to be in a new line, alphabetic ordering is not necessary.
The method you linked to is probably overkill for what you want.
Do a for /r loop to get all files recursively and set a variable named the same as the extension (the value isn't important, we need only the variable to be defined)
Then do a for /f loop to list the variables (with set . - all of them start with a dot conveniently because the %%~x modifier gets the extension with the dot (.txt)). Then just sort them alphabetically, if needed:
#echo off & setlocal
for /r %%a in (*) do set "%%~xa=X" 2>nul
for /f "delims==" %%a in ('set .') do echo %%a
(edit: removed the sort, because set . already sorts alphabetically - thank you #LotPings for the hint)

Rename Multiple file on using .cmd or .bat [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have directory which contain no. of file like this
abac_273#jj.txt ,
hhh.78448#kkpp.txt ,
dgfhf#ytyt#llltyui.txt
I need to write batch script where I need to rename those file like this
jj.txt , kkpp.txt, llltyui.txt
In simple words, I need to find out # from end and return string after # as output.
Can you please help me out to solve this
for /f "tokens=1*delims=#" %%a in ('dir /b /a-d "*#*"') do echo(ren "%%a#%%b" "%%b"
should provide what you want - reduce each %% to % if you execute this from the prompt instead of as a batch line.
If it works correctly for you, change the echo(ren to ren to actually do the change - this code will simply report the proposed change to the screen.

How do you find the last modified folder in a directory with command prompt? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
In the end, I want to copy the last modified folder in a directory. In order to do this, I need to pass in the name of the last modified folder to xcopy.
How do you find the last modified folder, not file, in a directory with command prompt? I have found many scripts that will find the last modified file, but I cannot seem to find a command that will find the last modified folder.
Any help would be appreciated.
#echo off
for /f "delims=" %%a in (' dir /ad /od /b ') do set "folder=%%a"

Findstr -- exclude a file type -- search only ascii [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to run a FINDSTR dos command in a way beyond what it is easily found in "findstr /?". How would I run findstr so that it only searches ascii files. (I am not sure if that is possible. My gut feeling is that it is not possible) Additionally, how would I run this command line so that it would exclude some file times. For example, what if I wanted to exclude .psd files
What is wrong with the /P option that is described in the help?
/P Skip files with non-printable characters.
It worked for me.
To take further control of which files are searched, simply iterate the files with a for loop and add whatever logic you need. To skip .psd files and also skip binary files:
for /f "eol=: delims=" %%F in ('dir /a-d /b^|findstr /live ".psd"') do findstr /p "search" "%%F"
Use a single percent instead of double percents if run from the command line.

Windows command prompt (Dos) copies all the files that start with the specified file name [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
In Dos if you type
copy c:\a.txt
it will copy a.txt* (a.txt1, a.txtb, etc)
how can I just copy a.txt?
Your question is not correct - copy c:\a.txt will only copy the single file to the current directory. It will ignore the other files like a.txt1 and a.txtb.
You must have tried copy c:\*.txt - that will copy all forms because the pattern matching searches both long and short (8.3) names.
You can eliminate the problem by using FINDSTR:
for /f "eol=: delims=" %F in ('dir /b /a-d c:\*.txt^|findstr /eli ".txt"') do #copy "c:\%F"

Resources