Jump to content

move 1 file into a new folder


Recommended Posts

hi everyone,

I have a folder w/ say 10 .jpg or .txt files. I would like to take 1 file at a time and create a new folder starting with # 1,2,3,etc to move it into.

currently i am able to move ALL files in a folder into another directory using filemove. but i would just like to move 1 and then create incremental folder names

here is an example of what i'm trying to do:

source\ randomname.jpg to \1\randomname.jpg

source\ randomname.jpg to \2\randomname.jpg

etc

i tried piecing this together but not sure how to get it finished and working. Any help would be greatly appreciated!

$sourceFolder = @ScriptDir & "\source"
$destination = @ScriptDir & "\destination" ;UNSURE WHAT TO PUT HERE TO GET THE INCREMENTAL FOLDER NAME

$folderlist = _FileListToArray($sourceFolder)

$numberoffiles = $folderlist[0]

MsgBox(0,"","There are " & $numberoffiles & " to be moved.")

If $numberoffiles = 0 Then
    MsgBox (0,"","No Files Found.")
    Exit
EndIf

For $i = 1 to $numberoffiles Step 1

    $oldfolder = $sourceFolder & "\" & $folderlist[$i]
    $newfolder = $destination & "\" & ;UNSURE WHAT TO PUT HERE TO GET THE INCREMENTAL FOLDER NAME & "\.jpg"

    FileMove($oldfolder, $newfolder)
Next

MsgBox (0,"","Moved a total of " & $numberoffiles)
Link to comment
Share on other sites

#Include <File.au3>
$sourceFolder = @ScriptDir & "\source"
$destination = @ScriptDir & "\destination" ;UNSURE WHAT TO PUT HERE TO GET THE INCREMENTAL FOLDER NAME

$folderlist = _FileListToArray($sourceFolder)

$numberoffiles = $folderlist[0]

MsgBox(0,"","There are " & $numberoffiles & " to be moved.")

If $numberoffiles = 0 Then
    MsgBox (0,"","No Files Found.")
    Exit
EndIf

For $i = 1 to $numberoffiles Step 1
    $oldfolder = $sourceFolder & "\" & $folderlist[$i]
    $newfolder = $destination & "\" &$i& "\" ;<--
    FileMove($oldfolder, $newfolder, 8+1);<--
Next

MsgBox (0,"","Moved a total of " & $numberoffiles)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

#Include <File.au3>
$sourceFolder = @ScriptDir & "\source"
$destination = @ScriptDir & "\destination" ;UNSURE WHAT TO PUT HERE TO GET THE INCREMENTAL FOLDER NAME

$folderlist = _FileListToArray($sourceFolder)

$numberoffiles = $folderlist[0]

MsgBox(0,"","There are " & $numberoffiles & " to be moved.")

If $numberoffiles = 0 Then
    MsgBox (0,"","No Files Found.")
    Exit
EndIf

For $i = 1 to $numberoffiles Step 1
    $oldfolder = $sourceFolder & "\" & $folderlist[$i]
    $newfolder = $destination & "\" &$i& "\" ;<--
    FileMove($oldfolder, $newfolder, 8+1);<--
Next

MsgBox (0,"","Moved a total of " & $numberoffiles)

OMG! thank you very much!! really that was all i needed huh? I appreciate the help

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