Jump to content

Recommended Posts

Posted (edited)

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

Posted (edited)

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

Might want to just "list" the files with the extention he is after

$loc = '*.***'

should be placed after...

$uExt = InputBox('The Extenstion','What is the extenstion for the files we are moving?','txt')

and do this....

$loc = '*.' & $uExt

8)

NEWHeader1.png

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
×
×
  • Create New...