Super User Asked on January 1, 2022
I need to rename (in particular not to copy nor to move) in Windows 8.1
this file path
D:Usershynek01703.08094.pdf – zástupce
to this path
C:Usershynek01703.08094.pdf – zástupce
Here, – zástupce
is the Czech word for reference (.lnk) file.
Note the different disks D:
and C:
here.
But I do know how to rename this if it is on the same disk and directory:
C:Usersa.pdf
to
C:Usersb.pdf
Also and more generally I would like to rename all files
D:Usershynek0*.pdf – zástupce
to
C:Usershynek0*.pdf – zástupce
And finally without – zástupce
:
D:Usershynek0*.pdf
to
C:Usershynek0*.pdf
Why not just remove unwanted strings?
Ren "C:Usershynek0*.pdf – z?stupce.lnk" "*.pdf.lnk"
:: or, without/removing .lnk ::
Ren "C:Usershynek0*.pdf – z?stupce.lnk" "*.pdf"
Or, copying renaming this files:
copy "D:Usershynek0*.pdf – zástupce.lnk" "C:Usershynek0*.pdf.lnk"
rem :: or, wit removing .lnk ::
copy "D:Usershynek0*.pdf – zástupce.lnk" "C:Usershynek0*.pdf"
You also can use substring:
rem :: string: .pdf – zástupce.lnk
rem :: |||||||||||||||||||
rem :: length: 1234567890123456789 == 19
rem :: recursive loop rename and removing the last 19 characters: "%_name:~0,-19%.lnk"
for /r "C:Usershynek0" %i in (*.lnk)do set "_name=%~nxi" && @call ren "%~i" "%_name:~0,-19%.lnk"
rem :: rename removing the last 19 characters: "%_name:~0,-19%.lnk"
Some further reading:
Answered by iTwasnTme on January 1, 2022
You are misunderstanding what Rename actually means.
Rename means changing the name or extension of a certain file or folder. What you trying to do is a move operation.
You have to first copy the PDF file to the same folder on D drive to C drive. Then you have to delete the file in D drive. Then the PDF will exist in the folder on C drive.
Like this you can use a Batch script for moving all PDF files:
@echo off
cd "Source path"
for %%a in (*.pdf) do (
move "%%~fa" "Destination path"
)
exit /b 0
Answered by programmer365 on January 1, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP