Good morning all,
I've been googling around to piece together a macro for uniformly re-naming files in Windows, but the methods I've found all seem to be different (and also don't do exactly what I need).
In short, I've got several directories containing a lot of pdf files. These files need to be re-named with a prefix (the same prefix for all files).
Example: the file 12345.pdf gets renamed to reissue 12345.pdf, where "reissue" is the prefix to be added to all files in the directory.
Rather than use a 'fixed' macro to perform the task this once, I'd like to pull in variables from cells in Excel, so that the file can be used as a utility for the future, for different locations and with a different prefix (and eventually a suffix, but that's a tweak for another day).
In the past, you've very kindly helped me with a macro that pulls in a list of file names from a fixed directory. This time, as I don't actually need the list to be imported into Excel, it seems like a waste to pull them in if I can just rename the files in a kind of for/next loop.
What I'd like to end up with:
• The working directory is entered into cell A1
• The desired prefix is entered into cell A2
• A macro to be activated which looks in directory A1, and re-names each file in there with the value of A2 at the start.
I'm not asking you folks to write the whole macro for me as such, but can you give me some pointers towards setting the working directory from a cell, and creating the loop that will rename files without pulling a list into Excel?
As always, thank you in advance for your time!
B.
I've been googling around to piece together a macro for uniformly re-naming files in Windows, but the methods I've found all seem to be different (and also don't do exactly what I need).
In short, I've got several directories containing a lot of pdf files. These files need to be re-named with a prefix (the same prefix for all files).
Example: the file 12345.pdf gets renamed to reissue 12345.pdf, where "reissue" is the prefix to be added to all files in the directory.
Rather than use a 'fixed' macro to perform the task this once, I'd like to pull in variables from cells in Excel, so that the file can be used as a utility for the future, for different locations and with a different prefix (and eventually a suffix, but that's a tweak for another day).
In the past, you've very kindly helped me with a macro that pulls in a list of file names from a fixed directory. This time, as I don't actually need the list to be imported into Excel, it seems like a waste to pull them in if I can just rename the files in a kind of for/next loop.
What I'd like to end up with:
• The working directory is entered into cell A1
• The desired prefix is entered into cell A2
• A macro to be activated which looks in directory A1, and re-names each file in there with the value of A2 at the start.
I'm not asking you folks to write the whole macro for me as such, but can you give me some pointers towards setting the working directory from a cell, and creating the loop that will rename files without pulling a list into Excel?
As always, thank you in advance for your time!
B.