Sign in to follow this  
Followers 0
behdadsoft

DirMove Need Guide

20 posts in this topic

#1 ·  Posted (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 by behdadsoft

Share this post


Link to post
Share on other sites



can the new name autmatic created ?

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Spider001

Share this post


Link to post
Share on other sites

I don't think _PathSplit solve this problem. because I have sub folder and need all folder rename auomatically.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

give us a output from

use a msgbox or ConsoleWrite to what you got with that

$i & $aArray[$i]
Edited by Spider001

Share this post


Link to post
Share on other sites

don't show any messange.

Share this post


Link to post
Share on other sites

there is any way for solve this Problem?

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

just like JLogan3o13 says and if you what the number not on the last place you need _PathSplit like i said before

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#17 ·  Posted (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 by Spider001

Share this post


Link to post
Share on other sites

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]?

Share this post


Link to post
Share on other sites

behdadsoft, again, read the help file instead of expecting people to spoon feed you everything! At the very least look at the Wiki - Arrays


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

look at the help for _arraydisplay()

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0