Jump to content

multiple directory copy


shay
 Share

Recommended Posts

Hi all

i`m having problem copying files from multiple folders

main directory named "logs"

all sub folders start with "log...."

and the files that i need to copy have the same name in every so i have to rename them

folder example:

-logs (main dir)

-log.1234 (sub folders)

-log.1235 (sub folders)

-log.1236 (sub folders)

how can i find the file and mass rename it (cause the have same name)??

Edited by shay

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

I used this once ... its ugly but works

#include <File.au3>

Dim $File = @ScriptDir & '\find.txt'
Dim $Where

$Dir = InputBox('Original File Place','Where are the files to move?','C:\log\')
$NewLocation = InputBox('New Location','Where would you like to store new files?','C:\NewLocation\New\')
$uExt = InputBox('The Extenstion','What is the extenstion for the files we are moving?','txt')
$loc = '*.'&$uExt

RunWait(@ComSpec & ' /c ' & 'dir "' & $Dir &$loc& '" /a :h /b /s' & ' > "' & @ScriptDir & '\find.txt"', '', @SW_HIDE)

_FileReadToArray($File, $where)

For $x = 1 to $where[0]
    if StringInStr($where[$x],'.'&$uExt,0) = 0 Then
        sleep(100)
    Else
    $Ext = StringRight($where[$x],4)
    $In = StringInStr($where[$x],'\',0,-1)
    $Len = StringLen($where[$x])
    $Out = $len - $in
    $Name = StringMid($where[$x],$In+1,$Out-4)
    $Final = $NewLocation & $name&$x&$Ext
    FileCopy($where[$x], $Final, 9)
    EndIf
Next

FileDelete(@ScriptDir & '\find.txt')
MsgBox(0,'','Complete')

Updated. to add valuaters addition ^_^

Edited by lordicast
[Cheeky]Comment[/Cheeky]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...