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:

[TABLE="width: 748"]
<tbody>[TR]
[TD="width: 748"]ren "OLD_NAME.pdf" "NEW_NAME.pdf"[/TD]
[/TR]
</tbody>[/TABLE]

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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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