sgeva Posted September 1, 2008 Share Posted September 1, 2008 Is there a command which move all the files from a directory and all its subdir to one dir -- but only files!! ? thank you Link to comment Share on other sites More sharing options...
Andreik Posted September 1, 2008 Share Posted September 1, 2008 Is there a command which move all the files from a directory and all its subdir to one dir -- but only files!! ?thank youYou can use DirMove() or DOS command xcopy. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
sgeva Posted September 1, 2008 Author Share Posted September 1, 2008 You can use DirMove() or DOS command xcopy. But this cmd moves also the name of the subdir .I want to move ONLY the files.thank you Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 1, 2008 Share Posted September 1, 2008 You could use FileCopy() in a loop. It accepts wildcards so you can move all the files and do a bit of recursion and you'll have everything you need. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
oMBRa Posted September 1, 2008 Share Posted September 1, 2008 U can do it taking each folder one by one then move the files in your folder Link to comment Share on other sites More sharing options...
Sanku1 Posted September 1, 2008 Share Posted September 1, 2008 FileDelete("C:\New Folder\*.JPG") Read the HelpFile to know more about it. Link to comment Share on other sites More sharing options...
Andreik Posted September 1, 2008 Share Posted September 1, 2008 (edited) Read oMBra suggest. Use _FileReadToArray to put all files from one dir in one array and then you can use FileCopy(). Edited September 1, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
sgeva Posted September 5, 2008 Author Share Posted September 5, 2008 (edited) Read oMBra suggest.Use _FileReadToArray to put all files from one dir in one array and then you can use FileCopy().Thank all of you for your help.I write it in this way:FileChangeDir("my_dir"); Shows the dirnames in the current directory.$search = FileFindFirstFile("my_dir\*.*") While 1 $dir = FileFindNextFile($search) If @error Then ExitLoop ; move all the mp3 files in every dir found FileMove( $dir & "\*.mp3", "target_dir", 9)WEnd; Close the search handleFileClose($search) Edited September 5, 2008 by sgeva Link to comment Share on other sites More sharing options...
rasim Posted September 5, 2008 Share Posted September 5, 2008 Thank all of you for your help. I write it in this way: FileChangeDir("my_dir") ; Shows the dirnames in the current directory. $search = FileFindFirstFile("my_dir\*.*") While 1 $dir = FileFindNextFile($search) If @error Then ExitLoop ; move all the mp3 files in every dir found FileMove( $dir & "\*.mp3", "target_dir", 9) WEnd ; Close the search handle FileClose($search)But your code don`t processing subdirectories. Example: _FileMoveEx("d:\Music\Metallica", "c:\Test", "mp3") Func _FileMoveEx($sSource, $sDest, $sExt) Local $iSearch = FileFindFirstFile($sSource & "\*.*") If $iSearch = -1 Then Return SetError(1, 0, 0) Local $sFile, $sFullFile While 1 $sFile = FileFindNextFile($iSearch) If @error Then ExitLoop $sFullFile = $sSource & "\" & $sFile If StringInStr(FileGetAttrib($sFullFile), "D") Then _FileMoveEx($sFullFile, $sDest, $sExt) If StringRight($sFullFile, 4) = ".mp3" Then FileMove($sFullFile, $sDest) WEnd FileClose($iSearch) EndFunc Link to comment Share on other sites More sharing options...
sgeva Posted September 5, 2008 Author Share Posted September 5, 2008 But your code don`t processing subdirectories. Example: _FileMoveEx("d:\Music\Metallica", "c:\Test", "mp3") Func _FileMoveEx($sSource, $sDest, $sExt) Local $iSearch = FileFindFirstFile($sSource & "\*.*") If $iSearch = -1 Then Return SetError(1, 0, 0) Local $sFile, $sFullFile While 1 $sFile = FileFindNextFile($iSearch) If @error Then ExitLoop $sFullFile = $sSource & "\" & $sFile If StringInStr(FileGetAttrib($sFullFile), "D") Then _FileMoveEx($sFullFile, $sDest, $sExt) If StringRight($sFullFile, 4) = ".mp3" Then FileMove($sFullFile, $sDest) WEnd FileClose($iSearch) EndFuncthank you I am a beginner but I try my program . I create test case: I create a dir : my_dir and put under it 2 subdirectories t1 and t2 Then I put 2 files in t1 and 2 files in t2. The program moved the 4 files from subdirectors t1 t2 to target dir I am missing something? thank you Link to comment Share on other sites More sharing options...
rasim Posted September 5, 2008 Share Posted September 5, 2008 thank youI am a beginner but I try my program .I create test case: I create a dir : my_dir and put under it 2 subdirectories t1 and t2Then I put 2 files in t1 and 2 files in t2.The program moved the 4 files from subdirectors t1 t2 to target dirI am missing something?thank youWhat wrong? You asked:Is there a command which move all the files from a directory and all its subdir to one dir -- but only files!! ? Link to comment Share on other sites More sharing options...
sgeva Posted September 5, 2008 Author Share Posted September 5, 2008 What wrong? You asked:I do not undersatnd.I applied my program to my_dir and the program found the subdir t1 and t2 and moved only their files without the name of the dir t1 t2.Do you know a command which can do it without the need of writing a program?thank you Link to comment Share on other sites More sharing options...
picaxe Posted September 5, 2008 Share Posted September 5, 2008 Do you know a command which can do it without the need of writing a program?for /r %i in (*) do move %i . Link to comment Share on other sites More sharing options...
sgeva Posted September 6, 2008 Author Share Posted September 6, 2008 for /r %i in (*) do move %i .Sorry but it is to much for me. Please explain the command or refer me . thank you Link to comment Share on other sites More sharing options...
picaxe Posted September 6, 2008 Share Posted September 6, 2008 (edited) This windows (tested on winxp) commandline for /r %i in (*) do move %i . will move all files from a subdir of the current dir to the current dir Is there a command which move all the files from a directory and all its subdir to one dir -- but only files!! ? thank you or for /r c:\temp\tmp %i in (*) do move %i \zzz move all files from c:\temp\tmp and its subdirs to c:\zzz. Move only works where source and destination dirs are on the same drive. Of course you will need to do a copy/delete otherwise. Edited September 6, 2008 by picaxe Link to comment Share on other sites More sharing options...
sgeva Posted September 6, 2008 Author Share Posted September 6, 2008 This windows (tested on winxp) commandline for /r %i in (*) do move %i . will move all files from a subdir of the current dir to the current dir or for /r c:\temp\tmp %i in (*) do move %i \zzz move all files from c:\temp\tmp and its subdirs to c:\zzz. Move only works where source and destination dirs are on the same drive. Of course you will need to do a copy/delete otherwise. 1. I try to compile this command : for /r D:\test %i in (*) do move %i D:\test1 and get error : ERROR: syntax error for / ~~~~^ 2. what is the meaning of %i and /r? 3. copy has no limits of the same drive for source and destination which move has? thank you Link to comment Share on other sites More sharing options...
picaxe Posted September 6, 2008 Share Posted September 6, 2008 It's windows command line, so in AutoIt you need something like$source = "c:\temp\tmp" $destination = "c:\zzz" Run(@ComSpec & ' /c for /r "' & $source & '" %i in (*) do move %i "' & $destination & '"')%i is not an AutoIt variable, it's used by the "for" command. Type "help for" in a windows cmd window or Google "windows xp for command" for more info. Link to comment Share on other sites More sharing options...
sgeva Posted September 6, 2008 Author Share Posted September 6, 2008 It's windows command line, so in AutoIt you need something like$source = "c:\temp\tmp" $destination = "c:\zzz" Run(@ComSpec & ' /c for /r "' & $source & '" %i in (*) do move %i "' & $destination & '"')%i is not an AutoIt variable, it's used by the "for" command. Type "help for" in a windows cmd window or Google "windows xp for command" for more info.Thank you very much I have learned a lot from you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now