AnswerBun.com

How do I rename the **entire** path

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

2 Answers

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

Add your own answers!

Related Questions

putty with ClientAliveInterval keepalive packets?

0  Asked on December 9, 2021 by geek11

     

How to remove Zoom “Talking:” pop up on second screen

1  Asked on December 8, 2021 by gabriella

 

How to close all open windows at once?

12  Asked on December 7, 2021

 

dual monitor ubuntu issue

1  Asked on December 7, 2021 by kbell

       

UUID and Drive Cloning

1  Asked on December 7, 2021

         

Some numbers wont light up in Network Cable Tester

1  Asked on December 7, 2021 by esther-t

   

How to tell if an external USB hard drive is spun down?

0  Asked on December 7, 2021 by duncan-bayne

       

Old school boom box input equivalent using SoX

1  Asked on December 7, 2021 by alant

       

Docker container not using host /etc/resolv.conf

2  Asked on December 7, 2021 by etienne-miret

     

Chrome password check alert

1  Asked on December 6, 2021 by amo

   

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP