4/1/2023 0 Comments Mass rename fileThe idea is to examine the contents of File.Path to determine whether it's a file you want to rename, and parse it to build the name of the new file.įinally, to call the routine, you need only code LoopThroughFiles "D:\Anime\One Piece". String File.Path contains the entire path and file check out the properties of the File object if you'd like more detail. Put your code to rename files between lines 15 and 18. Otherwise, keep or remove them at your pleasure. If you have folders under "D:\Anime\One Piece" containing files you'd prefer to ignore for these purposes, you can remove lines 11-14. I'll reproduce it here: Private Sub LoopThroughFiles(ByVal TargetFolder As String)ĭim Folder As Object, SubFolder As Object, File As Object, FQueue As New Collectionĭim FSO As Object: Set FSO = CreateObject("Scripting.FileSystemObject") The redoubtable /u/ViperSRT3g has provided us with a splendid routine to loop through the files a folder and its subfolders. The alternative is to have code look through your files and rename the ones you want renamed the way you want them renamed. Let me know if it's not quite what you're looking for. I hope I'm understanding the issue correctly. These two lines would give you strings for the file name (with extension removed) and just the extension. Before doing that, you may want to pop the file extension in a separate string variable using:ĮxtName = Right(FileName, InStrRev(FileName, ".") - 1) This would be assuming that the filename(s) you have loaded include the extension at the end. NewFileName = Mid(FileName, 1, InStrRev(FileName, ".") - 1) mkv (or any) extension issue using something like: From there, you could scan through the files and rename them however you like. Assuming you have made use of the File System Object to be able to rename files (if not, look into that), you should be able to use it to get a list of files / folders in any given directory. To be able to rename a file, it would have to know exactly which one. For example, moving PDF and DjVu files transcluded at the Wikisources is problematic for those wikis and should be avoided unless the file mover understands the consequences. One Piece and Excel - two things I love coming together! I'm guessing Name in your code refers to another Sub or Function. Additional naming conventions and exceptions from the above list might be discussed for specific projects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |