Paste column from Excel to Command Prompt

dlz217

New Member
Joined
Aug 23, 2013
Messages
49
I have a spreadsheet that takes a list of file names, modifies new file names, and creates the "ren" command to execute using command prompt. So I may have 50 rows from F2:F51 that look like this:

ren "OLD_NAME.pdf" "NEW_NAME.pdf"

<tbody>
</tbody>

I want to create a macro that pastes this into CMD to run. Normally, you can open CMD and just paste that column manually. Is this possible?
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I was able to run CMD and generate the file list using the below. I just need to figure out how to paste the cell value into command.

Code:
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1


wsh.Run "cmd.exe /S /C cd C:\Users\...\...\... & dir /b > _list.txt", windowStyle, waitOnReturn
 
Upvote 0
You can rename files using a native VBA Name statement like this:
Code:
Name Range("F2") As Range("G2")
where cells F2 and G2 contain the old name and new name, respectively.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top