By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Move all files to a new folder, and delete files in original folder

100+
P: 547
I have files in the following folder with a ".out" extention. c:\rt\rfidlogs\.out" and need to move all these ".out" files to c:\rt\rfiderrors\ folder, and then delete the original in the rfidlogs folder
Cannot get it to work
Expand|Select|Wrap|Line Numbers
  1. FileCopy "c:\rt\rfidlogs\*.out", "c:\rt\rfiderrors\"
  2. Close #1
  3.    Kill "C:\RT\rfidlogs\*.out"
Please guide me
Aug 31 '12 #1

✓ answered by zmbd

yes but why call another library reference?

Expand|Select|Wrap|Line Numbers
  1. Sub testmove()
  2. Name %1 As %2
  3. End Sub
Where %1 is the full name and path to the file of interest
and %2 is the full name and path to the new location.
You can also take the Dir function results to an array and then use the array to feed the code above the old and new names...

(edit: array or a collection... either way... google search will turn up tons of code to handle recursion too)

http://www.applecore99.com/gen/gen061.asp

-z

Share this Question
Share on Google+
4 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,055
I believe the best way would be to copy and kill each file individually.
Aug 31 '12 #2

P: 25
I prefer using the file system object
Expand|Select|Wrap|Line Numbers
  1.     Dim FSO As Object
  2.     Set FSO = CreateObject("scripting.filesystemobject")
  3.     FSO.MoveFile "c:\rt\rfidlogs\*.out", "c:\rt\rfiderrors\"
or with reference set to 'microsft scripting runtime' then IntelliSense will work
Expand|Select|Wrap|Line Numbers
  1.     Dim fs As New FileSystemObject
  2.     fs.MoveFile "c:\rt\rfidlogs\*.out", "c:\rt\rfiderrors\"
Aug 31 '12 #3

zmbd
Expert Mod 5K+
P: 5,287
yes but why call another library reference?

Expand|Select|Wrap|Line Numbers
  1. Sub testmove()
  2. Name %1 As %2
  3. End Sub
Where %1 is the full name and path to the file of interest
and %2 is the full name and path to the new location.
You can also take the Dir function results to an array and then use the array to feed the code above the old and new names...

(edit: array or a collection... either way... google search will turn up tons of code to handle recursion too)

http://www.applecore99.com/gen/gen061.asp

-z
Aug 31 '12 #4

NeoPa
Expert Mod 15k+
P: 31,186
Neels, the problem with your code is probably that line #2 hasn't run before you start, but Z's suggestion is a far better approach all round. Set it as Best Answer now is my advice ;-)
Aug 31 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.