Jump to content
Sign in to follow this  
13lack13lade

filefind filemove keeping same name

Recommended Posts

13lack13lade

Hi Everyone!

I have a bunch of files named thomas_blahblahblahba_blahbalh_blah.doc in a folder, i want to keep the file names and simply move them to another folder.

Ive had a look at the filefind in help folder and filemove but the examples shown in the help file dont really help me.. i can move files if i list the name in the code itself however i just want the script to keep the file names and just move to another folder because there are so many files..

Is this fairly simple to achieve?

Share this post


Link to post
Share on other sites
sahsanu
I have a bunch of files named thomas_blahblahblahba_blahbalh_blah.doc in a folder, i want to keep the file names and simply move them to another folder.

 

Ive had a look at the filefind in help folder and filemove but the examples shown in the help file dont really help me.. i can move files if i list the name in the code itself however i just want the script to keep the file names and just move to another folder because there are so many files..

Is this fairly simple to achieve?

 

If I've understood your question, yes it is fairly simple, with the FileMove function you should be able to move all of them at once:

FileMove("c:\sourcedir\thomas_*_*_*.doc", "c:\destinationdir\*", 9)

Cheers,

sahsanu

Share this post


Link to post
Share on other sites
13lack13lade

oh wow, didnt know you could move them all at once thought i would have to loop it or something..

Thanks for that sahsanu!

Share this post


Link to post
Share on other sites
sahsanu

oh wow, didnt know you could move them all at once thought i would have to loop it or something..

Thanks for that sahsanu!

 

You are welcome :D

Share this post


Link to post
Share on other sites
13lack13lade

Is there a way to stop a loop half way through or every say 500 rows to run another line of script?

#include <Excel.au3>

;enter excel data into calypso
$oExcel = _ExcelBookOpen("\\fbnecl3\inzb\Documents\Load Support\Book1.xlsx")

   winactivate("Calypso Host")
   sleep (700)
   Send("DA")
   
   For $i = 1 To 2700 ;Loop
    $TypCellValue = _ExcelReadCell($oExcel, $i, 1)
    $CityCellValue = _ExcelReadCell($oExcel, $i, 2)
    $PrdCellValue = _ExcelReadCell($oExcel, $i, 3)


 sleep(100)
   Send("{TAB}")
 Sleep(100)
   Send($TypCellValue)
 Sleep(100)
   Send($CityCellValue)
 Sleep(100)
   Send("+{DELETE}")
 Sleep(100)
   Send($PrdCellValue)
 Sleep(100)
   Send("{ENTER}")
       Sleep(100)
   Send("+{F12}")
  Sleep(100)
   Send("C")
 Sleep(100)
   Send("{TAB}")
 Sleep(100)
   Send("{ENTER}")
 Sleep(100)
   Send("{NUMPADMULT}")
 Sleep(100)
   Send("thomas_")
 Sleep(100)
   Send($TypCellValue)
 Sleep(100)
   send("_")
 Sleep(100)
   Send($CityCellValue)
Sleep(100)
   send("_")
Sleep(100)
   Send($PrdCellValue)
 Sleep(100)
   send(".doc")
 Sleep(100)
   send("{TAB}")
 Sleep(100)
   Send("PC")
 Sleep(100)
   send("{ENTER}")
 Sleep(100)
   send("{ESC}")
   
Next


Sleep(60000)


FileMove("\\calypso.au.flitech.net\reports\loadtext\thomas_*_*_*.doc", "\\fbnecl3\inzb\Documents\ATI - LOAD\ATI - LIVE\CPL Migration\Supplier Notes\*", 9)

I have this script created to extract data from our database but our reports folder only holds a certain amount of mb before its full so i want to move the data accross every 400-500 codes - is there a way to build it in?

So have the script run the last line whenever $i hits 400/500 multiple.. eg 800/1000, 1200/1500

Edited by 13lack13lade

Share this post


Link to post
Share on other sites
13lack13lade

Also is there a way to rename the files afterwards to remove the thomas_ at the start of each file using 1 line of code like previously? so they keep there name just remove the first 7 characters i guess? :D

 

Apologies for the 50 questions at once...  :imwithstupid: 

Edited by 13lack13lade

Share this post


Link to post
Share on other sites
sahsanu

As you are asking different questions, next time please, open a new thread ;)

 

Is there a way to stop a loop half way through or every say 500 rows to run another line of script?

I have this script created to extract data from our database but our reports folder only holds a certain amount of mb before its full so i want to move the data accross every 400-500 codes - is there a way to build it in?

 

So have the script run the last line whenever $i hits 400/500 multiple.. eg 800/1000, 1200/1500

 

 

Yes, it is possible.

Also is there a way to rename the files afterwards to remove the thomas_ at the start of each file using 1 line of code like previously? so they keep there name just remove the first 7 characters i guess? :D

 

Apologies for the 50 questions at once...  :imwithstupid:

 

There is a way to Trim the first 7 characters but it is not so simple.

I've modified your script to move files every 400 rows and when the last row is processed and rename the files removing the first 7 characters "thomas_" when you move them. Double check it before put it in production ;)

#include <Excel.au3>
#include <File.au3>

;enter excel data into calypso
$oExcel = _ExcelBookOpen("\\fbnecl3\inzb\Documents\Load Support\Book1.xlsx")

WinActivate("Calypso Host")
Sleep(700)
Send("DA")

$dosomethingevery = 400 ;move files every x times
$dosomethingreached = $dosomethingevery
$finalcount = 2700
For $i = 1 To $finalcount ;Loop

    $TypCellValue = _ExcelReadCell($oExcel, $i, 1)
    $CityCellValue = _ExcelReadCell($oExcel, $i, 2)
    $PrdCellValue = _ExcelReadCell($oExcel, $i, 3)


    Send("{TAB}")
    Sleep(100)
    Sleep(100)
    Send($TypCellValue)
    Sleep(100)
    Send($CityCellValue)
    Sleep(100)
    Send("+{DELETE}")
    Sleep(100)
    Send($PrdCellValue)
    Sleep(100)
    Send("{ENTER}")
    Sleep(100)
    Send("+{F12}")
    Sleep(100)
    Send("C")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{ENTER}")
    Sleep(100)
    Send("{NUMPADMULT}")
    Sleep(100)
    Send("thomas_")
    Sleep(100)
    Send($TypCellValue)
    Sleep(100)
    Send("_")
    Sleep(100)
    Send($CityCellValue)
    Sleep(100)
    Send("_")
    Sleep(100)
    Send($PrdCellValue)
    Sleep(100)
    Send(".doc")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("PC")
    Sleep(100)
    Send("{ENTER}")
    Sleep(100)
    Send("{ESC}")
    ;Moving files every x times and when $finalcount is 2700
    if $i = $dosomethingreached Or $i = $finalcount Then ;if limit is reached (in the example every 400) or last line (2700) then move files
        $aFileList = _FileListToArray("\\calypso.au.flitech.net\reports\loadtext\", "thomas_*_*_*.doc", 1);need to put the file names into an array to process then later
        If @error = 4 Then
            ConsoleWrite("No files found: " & $i & @CRLF)
        Else
            For $f = 1 to $aFileList[0]
                $finalname = StringTrimLeft($aFileList[$f], 7) ;remove first 7 characters
                FileMove("\\calypso.au.flitech.net\reports\loadtext\" & $aFileList[$f], "\\fbnecl3\inzb\Documents\ATI - LOAD\ATI - LIVE\CPL Migration\Supplier Notes\" & $finalname, 9)
            Next
        EndIf
        $dosomethingreached = $dosomethingevery + $dosomethingreached ;increase the limit adding 400 every time
    EndIf

Next

Sleep(60000)

 

Share this post


Link to post
Share on other sites
13lack13lade

Apologies on not creating a new thread, i thought about doing that after i had posted the comments.. will seperate threads in future.

Wow that worked perfectly.

You have saved me lots of time and also helped me learn how to some more things in autoit!

Absolute champion thank you so much for your time, greatly appreciated...

Have a great weekend mate!

Edited by 13lack13lade

Share this post


Link to post
Share on other sites
sahsanu

Glad to help you.

Have a nice weekend you too ;-)

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  

×