behdadsoft Posted October 21, 2014 Posted October 21, 2014 (edited) Hi. I have more than 1 folder for rename. bow can rename array folders? should I use _FileListToArray for get list and rename them? Thanks Edited October 21, 2014 by behdadsoft
Moderators JLogan3o13 Posted October 21, 2014 Moderators Posted October 21, 2014 (edited) You could do something like this. As a quick example, given a root folder named Test on the desktop, with the subfolders Test1, Test2, Test3, Test4, Test5... #include <File.au3> Local $aArray = _FileListToArray(@DesktopDir & "\Test", "*", $FLTAR_FOLDERS, True) For $i = 1 To $aArray[0] DirMove($aArray[$i], $aArray[$i] & "_" & $i) Next would produce subfolders Test1_1, Test2_2, Test3_3, Test4_4, Test5_5. Edited October 21, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
behdadsoft Posted October 22, 2014 Author Posted October 22, 2014 Thanks. But I want add number at first folder name.I try this code but don't work. For $i = 1 To $aArray[0] DirMove($aArray[$i], $i & $aArray[$i]) Next
Spider001 Posted October 22, 2014 Posted October 22, 2014 (edited) like i see it you put the number before your drive c:/,.... use a msgbox or ConsoleWrite to what you got on that string $i & $aArray[$i] i think you must use _PathSplit then place your number and then assemble the whole path again Edited October 22, 2014 by Spider001
behdadsoft Posted October 22, 2014 Author Posted October 22, 2014 I don't think _PathSplit solve this problem. because I have sub folder and need all folder rename auomatically.
Spider001 Posted October 22, 2014 Posted October 22, 2014 (edited) give us a output from use a msgbox or ConsoleWrite to what you got with that $i & $aArray[$i] Edited October 22, 2014 by Spider001
behdadsoft Posted October 22, 2014 Author Posted October 22, 2014 there is any way for solve this Problem?
Moderators JLogan3o13 Posted October 22, 2014 Moderators Posted October 22, 2014 The problem you are going to run into is that when you change the top level folder's name first, you then alter the path for every subsequent folder. Try using the code I supplied to change all the sub folders, then change the parent folder last. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
behdadsoft Posted October 23, 2014 Author Posted October 23, 2014 Try using the code I supplied to change all the sub folders, then change the parent folder last. Your code change last folder name. how can move changes to first folder name? I need it Please Guide Me. Thanks.
Moderators JLogan3o13 Posted October 23, 2014 Moderators Posted October 23, 2014 Ok, I get that we have probably have a language barrier here, but you need to clarify what you're trying to do. From your OP, it seems like you have a number of folders that you want to rename, and you're using _FileListToArray to gather a list of the folders to be changed. (Right so far??) You can't change the top-level folder until last, because that would alter the path for every subsequent folder. So, once you have the array of folders, change all the subfolders first, then change the parent folder last. Something like this: All the same code I gave you in post #3 #include <File.au3> Local $aArray = _FileListToArray(@DesktopDir & "\Test", "*", $FLTAR_FOLDERS, True) For $i = 1 To $aArray[0] DirMove($aArray[$i], $aArray[$i] & "_" & $i) Next Change the parent directory last ;Last Step! DirMove(@DesktopDir & "\Test", @DesktopDir & "\NewTest", 1) If it is still not clear, then you need to explain in better detail what you're trying to do. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
behdadsoft Posted October 23, 2014 Author Posted October 23, 2014 OK, I explain better. I want rename Parent folder and sub folders. mean I have some parent folder that each have many sub folders. Now I want rename parents folder and sub folders.like this: 1 New Folder ---1 test ---2 test ---3 test 2 New Folder ---4 test ---5 test ---6 test and so on.
Spider001 Posted October 23, 2014 Posted October 23, 2014 just like JLogan3o13 says and if you what the number not on the last place you need _PathSplit like i said before
Moderators JLogan3o13 Posted October 23, 2014 Moderators Posted October 23, 2014 Please explain what the folders are named before you start, and then what they are named after you run the code I provided to you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
behdadsoft Posted October 24, 2014 Author Posted October 24, 2014 my folder names before start are like this: Game ---Evit ---StarWars ---IGI Software ---Firefox ---Chrome ---Babylon now I want add number at first name folders like this: 1 Game ---1 Evit ---2 StarWars ---3 IGI 2 Software ---4 Firefox ---5 Chrome ---6 Babylon
Solution Spider001 Posted October 24, 2014 Solution Posted October 24, 2014 (edited) #include <File.au3> #include <array.au3> $tel = 1 $tel1 = 1 Local $aArray = _FileListToArray(@DesktopDir , "*", $FLTAR_FOLDERS, True) If UBound($aArray) > 0 Then For $i = 1 To $aArray[0] Local $aArrays = _FileListToArray($aArray[$i] , "*", $FLTAR_FOLDERS, True) If UBound($aArrays) > 0 Then For $j = 1 To $aArrays[0] DirMove($aArrays[$j], _GetPathSplit($aArrays[$j])[1] & _GetPathSplit($aArrays[$j])[2] & $tel1 & _GetPathSplit($aArrays[$j])[3]) $tel1 += 1 Next EndIf DirMove($aArray[$i], _GetPathSplit($aArray[$i])[1] & _GetPathSplit($aArray[$i])[2] & $tel & _GetPathSplit($aArray[$i])[3]) $tel += 1 Next EndIf Func _GetPathSplit($file) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" Return _PathSplit($file, $sDrive, $sDir, $sFilename, $sExtension) EndFunc Edited October 24, 2014 by Spider001
behdadsoft Posted October 24, 2014 Author Posted October 24, 2014 Thanks Spider001. I have a ask can you explain me this line? DirMove($aArrays[$j], _GetPathSplit($aArrays[$j])[1] & _GetPathSplit($aArrays[$j])[2] & $tel1 & _GetPathSplit($aArrays[$j])[3]) what is [1],[2],[3]?
Moderators JLogan3o13 Posted October 24, 2014 Moderators Posted October 24, 2014 behdadsoft, again, read the help file instead of expecting people to spoon feed you everything! At the very least look at the Wiki - Arrays "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now