Jump to content

File Move Script Help


Recommended Posts

Hi Yall,

I need some help writing a simple script to automate a file move process. The backup software I am running can't handle more than a 100 files at a time. In addition, the file move from one folder to another is a bit tricky. I have the source file(i.e. test123.mov) and the matching fork file for it is(i.e. test123.mdf). I need to move both matching elements in the script to another folder path. The files ending in .mov and .mdf are unique. The file move for both *.mov and *.mdf cannot exceed 100 files for the move and the script needs to be in a way that if the backup software backups for example 30 files, the script moves over 30 more unique files.

The code below is something to work with and just might need a few things added/removed to it.

I would greatly appreciate anyone that can help me with this.

Global $Directory = "C:\Source"
Global $MoveDirectory = "C:\Moved"
$GetBatchFiles = _FileListToArray($Directory, "*.*")
If $GetBatchFiles[0] >= 100 Then
For $I = 1 To 100
         FileMove($Directory & "\" & $GetBatchFiles[$I], $MoveDirectory & "\" & $GetBatchFiles[$I])
         FileDelete($Directory & "\" & $GetBatchFiles[$I])
Next
EndIf
Func _FileListToArray($Path, $Filter = "*")
Local $Search, $File, $FileList[1]
$Search = FileFindFirstFile($Path & "\" & $Filter)
While 1
     $File = FileFindNextFile($Search)
     If @error Then ExitLoop
     ReDim $FileList[UBound($FileList) + 1]
     $FileList[0] += 1
     $FileList[UBound($FileList) - 1] = $File
WEnd
FileClose($Search)
Return $FileList
EndFunc ;==>_FileListToArray
Link to comment
Share on other sites

  • Moderators

automatetasks,

Please pay attention to where you post - this was in the "Examples" section which is clearly labelled "This is NOT a general support forum!". I have moved it for you this time, but I would be grateful if you could take more care in future. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

automatetasks, hello, got some questions, first, why do you have to use that other backup software?

Are all the files only .mov and .udf?

"the script needs to be in a way that if the backup software backups for example 30 files, the script moves over 30 more unique files."

Does this mean, that the backup software backs up some files, and you want them moved somewhere else, because they are already backed up?

I can see the point, since there are so many, you want them out of the way.

How can the script "see" the files were backed up? Are they copied to some folder?

The script needs to know what files have been backed up, so that then it can compare the filenames and move those to somewhere else.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Hi careca,

Answers

1. why do you have to use that other backup software?

--We use a backup software to backup all of our media files. I can't change this.

2. Are all the files only .mov and .udf?

-- Yes, all the files are .mov and .mdf

3. Does this mean, that the backup software backs up some files, and you want them moved somewhere else, because they are already backed up?

--The backup software looks at a particular folder, backups the files and then removes them from the folder. I am looking to sort the files to the backup location before they are backed up.

4. How can the script "see" the files were backed up?

--The script doesnt see if they are backed up. It doesn't need to interface with the backup software but the script looks at the folder and does a file count to see how many more files it can dump to it.

5. Are they copied to some folder?

--Yes, the .mov and .mdf files are moved to the backup folder where the backup software does its job.

Hope to answers your questions.

Link to comment
Share on other sites

Ok, i'll try to help, but i might come up with a totaly different script, with a gui, just because i think it's better.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Im back, here's what i got

;#region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Icon=.ico
;#AutoIt3Wrapper_Res_Icon_Add=.ico
;#AutoIt3Wrapper_Run_Tidy=y
;#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <RecFileListToArray.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayIconDebug", 1)

$Form1 = GUICreate("Simple Move", 600, 430, 190, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$cListView = GUICtrlCreateListView("Path", 10, 115, 580, 210)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 575)
$Backup = GUICtrlCreateButton("Move", 10, 380, 75, 25)
GUICtrlSetOnEvent($Backup, "Move")
$Source = GUICtrlCreateButton("Source", 515, 28, 75, 25)
GUICtrlSetOnEvent($Source, "Source")
$Dest = GUICtrlCreateButton("Dest", 515, 337, 75, 25)
GUICtrlSetOnEvent($Dest, "Dest")
$Label1 = GUICtrlCreateLabel("Source Folder", 10, 10, 130, 17)
$Label2 = GUICtrlCreateLabel("Extensions to search for: (separated by ; )", 10, 60, 200, 17)
$Label3 = GUICtrlCreateLabel("Destination Folder", 10, 220, 200, 17)
$Input1 = GUICtrlCreateInput(@ScriptDir, 10, 30, 500, 21)
$Input2 = GUICtrlCreateInput(@ScriptDir, 10, 340, 500, 21)
$Input3 = GUICtrlCreateInput("*.mov;*.mdf", 10, 80, 200, 21)
$SourceDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
$Ext = GUICtrlRead($Input3)
GUISetState(@SW_SHOW)

Func Source()
_GUICtrlListView_DeleteAllItems($cListView)
$SourceDir = FileSelectFolder("Choose Source Dir", '', 2, @DesktopDir)
GUICtrlSetData($Input1, $SourceDir)
$aList = _RecFileListToArray ($SourceDir, $Ext, 1, 0, 0, 2)
If IsArray($aList) Then
For $u = 1 To $aList[0]
GUICtrlCreateListViewItem($aList[$u], $cListView)
Next
EndIf
EndFunc

Func Dest()
$DestDir = FileSelectFolder("Choose Source Dir", '', 2, @DesktopDir)
GUICtrlSetData($Input2, $DestDir)
EndFunc

Func Move()
$SourceDir = GUICtrlRead($Input1)
$DestDir = GUICtrlRead($Input2)
$ItemCount = _GUICtrlListView_GetItemCount($cListView)
For $u = 0 To $ItemCount
$ItemText = _GUICtrlListView_GetItemText($cListView, $u, 0)
FileMove($ItemText, $DestDir, 9)
Next
EndFunc ;==>Backup

Func Close()
Exit
EndFunc ;==>Close

Do
Sleep(100)
$Ext = GUICtrlRead($Input3)
Until $Form1 = 0

Need's attached Melba's "RecFileListToArray.au3"

I think it is pretty simple to use, try out and tell what you think.

EDIT: For some reason the includes went blank! :S

RecFileListToArray.au3

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Please state what it should do or what function is missing, i remind it was done as a base script for you to build on.

It is something that can be altered according one's need.

Help me out so i can help you out. :)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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...