Hi to all,
i have to rename about 10k files, to which i have to add some code i retrieved with a query.
Right now I have, on one side the complete PATH of the file:
on the other hand I have the name that this file will have to assume:
Does anyone know how to do?
The idea is to look for the current name in the folder, (I don’t know how) and rename it. (this I know how to do)
Thanks to all
Did you try for each file in folder?
Inside that give rename and use new name as “new addition” + currentitem.name
Currentitem. Name would give the name of file and currentitem.fullname will give the path as well
I think I need some additional help.
How do I rename the correct files, with the correct string?
- The automation must read the file name in the folder.
(I think with an action like this: arrFile = directory.GetFiles(Folder_Path) )
Then, For Each File in Folder_Path…
at this point, i have the filename in the folder.
on DB the same name of the file, present in folder and in another column, the name of the file that it will have to assume.
but here i get stuck…
do i need to enter something like this?
For Each File in Folder Path:
if “File Folder Name” = “File Folder Column1 dt”
rename - File Folder Name >>> File Folder column2
Using Directory.GetFiles(“Folderpath”), you will get the collection of files. Use a for loop and loop through it.
Then use an if condition to check the file name.
So if you have the old and new file names in db then i hope you can get the data from
Sb using slect into datatable
Then loop theough the datatble and use
directory.getfiles("your base folder","*" + currentrow("oldfilecolumn").tostring + "*")(0) to get the first matched file with the given name …next step is to use replace
Previously my assumption was you need to add a specific constant value to all file names so i asked you to use for each file and add the data you need