Jump to content

help moving files


sbrady
 Share

Recommended Posts

is there a way I can move all files from the desktop to a certain folder, where all files needed to be moved have the same 1st word in their name.

for example:

EGR123 American Schools EM v1.mxf

EGR123 American Schools EMF v1.mxf

EGR123 American Schools v1.omf

I would need all files whose name starts with EGR123 to be moved.

thanks for any help.

Link to comment
Share on other sites

Something like this should work (untested):

#include<Array.au3>
#include <File.au3>

$myfiles=_FileListToArray(@DesktopDir)

;_ArrayDisplay($myfiles); to see all your files un-comment to use

for $a=1 to UBound($myfiles)-1
    FileMove($myfiles[$a],['PATH'&"\PREFIX_FILENAME")
next

The above will move all files.  I did not read your original post carefully enough.  You want to make sure the name contains "EGR123" then do this:

#include<Array.au3>
#include <File.au3>

$myfiles=_FileListToArray(@DesktopDir)

_ArrayDisplay($myfiles)

for $a=1 to UBound($myfiles)
    if StringInStr($myfiles[$a],"EGR123") <>0 then
        FileMove($myfiles[$a],['PATH'&"\PREFIX_FILENAME")
    EndIf
next
Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

  • Moderators

Jfish,

Just use the filter in _FileListToArray to only return those files beginning with "EGR123" in the first place - much more efficient. ;)

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

thanks mike, I plugged in a  variable and am getting this error:

 Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

here is my code:

#include<Array.au3> 
#include <File.au3> 
$myfiles =_FileListToArray(@DesktopDir ) 

local $news_project_full_name = InputBox(8192, "Paste in Project Name", "EGR123 Schools EM v1")
Local $news_name_no_EM_v1 = StringTrimRight($news_project_full_name, 6)   ;"EGR123 Schools"
Local $news_name_NPR = $news_name_no_EM_v1 & " NPR"
local $news_project_code =  StringLeft ( $news_project_full_name, 6 )   ;EGR123




for $a=1 to UBound($myfiles)     
   if StringInStr($myfiles[$a],$news_project_code)  then         
FileMove(@DesktopDir & $news_project_code & "*", $path_to_incoming)
EndIf 
   next
Link to comment
Share on other sites

Hum I don't know how you want to manage your folders but you can forget _FileListToArray() and simply do it like this (be very careful with managing the backslashes in paths)

$prefix = "EGR123"
$source_folder = @DesktopDir & "\"    ; the paths are examples
$dest_folder = @DesktopDir & "\folder\"

FileMove($source_folder & $prefix & "*", $dest_folder & "*")
Edited by mikell
Link to comment
Share on other sites

mike that last one worked. Thanks so much. You have no idea what a help you have been. I am an audio editor and we make folders all day long for each project and put the needed audio and video files in the new folder. This script that I'll make an exe will make things 1 click easy. thanks again.

be aware I have dozens of more scripts to write.

shawn

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