Jump to content

DirMove command questions


JohnWPB
 Share

Recommended Posts

Ok, my first post on the AutoIt forums. I have been using AutoIt for about a year now to suppliment features that the CarPC software Road Runner lacks. Until now, I have been able to work out what I needed to know from searching code examples and the well laid out AutoIt help file. Some of you may know me from the MP3Car Forums. I am a noob here, but certainly not to the forum or search scene :)

The problem I am having is a fairly simple one, that I can not for the life of me find a solution to.

Here is what I am using as code:

DirCopy($CurrentLocation,$FileDestination,1)oÝ÷ Ù8^¥«a±ªÞ¥«,y×ë¢dhiÔnw«¶.-ºÈ§Ø^r¦jwew«ÞÈ£ývØ^½©nzʶ¶½ªâi¹^±©Ý¶²j·µÓG(®··­z-­¨¥xiÉ,«!zÂn²Ûhvç!yɵë-yÛayú%"-jØr^¶z'Èr¥v­ÛhÂäjëh×6DirCopy("G:\NewMusic\The Doors", "E:\MP3", 1)

What is happening, is the individual MP3's in the "NewMusic" directory, are being dumped into the E:\MP3 directory.

(BTW, this is a part of a utility to copy music from a USB Hard Drive, Thumb Drive ect to the CarPC's Music folder. With around 2,000 people using my skin for their CarPC's it has to be totally dynamic as to the directory paths.)

So what I am ending up with is all of the MP3's being dumped to the root of the MP3 folder. I need to retain the directory structure and end up with E:\MP3\The Doors and all the associated MP3's in this sub folder.

This is working more like a file copy command, rather than a directory copy command for me. There has to be some work around or something I am missing. I have spent the past 2 hours scouring the help file and the forums on anything related to file handling and have come up empty handed.

Any help from your code guru's out there would be greatly appreciated!Posted Image

Edited by JohnWPB
Link to comment
Share on other sites

What you should be using is

DirCopy("G:\NewMusic\The Doors", "E:\MP3\The Doors", 1)
oÝ÷ ÙIåzË2¢ìׯz¼­)às^ÀˬȧÂƬzëjëh×6
DirCopy("G:\NewMusic", "E:\MP3", 1)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

What you should be using is

DirCopy("G:\NewMusic\The Doors", "E:\MP3\The Doors", 1)
oÝ÷ Ùj0¶§Çè®Ø^ªè·©-÷N®åzh¬¶­"¯{jZ¶rêëz{lzWµçijØZÖzËb«b¢zZ¶®®·§´ö­m=Ø×°2ë"sOvN¢ìÓݪºCzËb«b¢sÚ¶4÷cßOvNW¥¡Æ­ìj·¢h§úè¦ë£®ØZ´n¶Ú zØ^­8^ºÇ«Â)enº0±ëh¶¥¡Æ­è~Ø^¹®²'-ì°j{m¡Ê)ÊÚ-à¬ðë®*mË&j»^ Ú-zYb~+b±§âê+iú%uêí«pjËç-yÛhmç(¦'N§¶²²)©'%ɪê-rr2ë"r«¨µ»­¶ÚØ­¥«,zͯj¸nW®­êk¢
ÚÚºÚ¶Þ¶©jØm죺ËlzWµçbØ^nº0±êíê-êíêkzÇ­ë"r­8^±ç(×îZZ¶hzÉèµìb²Ûaz·¢·­êÞÉèÁ¬­¡ºèÂÇ¢µh^§âè¬rbyܨ¹Æ§²)©+É«­¢+Ù¥±
½Áä¡èÀäÈíQáйÑáаèÀäÈìÅÕ½Ðì°Ä¤oÝ÷ ٩ݶ­Â)eÂäb¢z-«Þ¶)yÈÊØ^©¡ûayø¥yú+¶zËb«b¢ybëaÆ®¶­sdfÆT6÷3¢b3#µFWBçGBÂC¢b3#·FWBç
xt",1)

The FileCopy command is smart enough to know what to name the file for the destination, and thats exactly what I was looking for when copying a folder to a new location.

I was REALLY trying to avoid sloppy code and having to work my way back a character at a time from the end of the CurrentPath variable with a for next loop, looking for a slash a character at a time from the end, (Can't use StringInString, as there may be multiple "\"'s in there) then having to subtract that amount of letters and pull that many from the right using a StringRight,x to complete the destination path by adding those letters to the end of that variable. That just seems like a bad workaround to do this.

With Xcopy the command would simply be:

xcopy G:\NewMusic\The Doors\ f:\MP3

and you would end up with F:\MP3\The Doors\ (And all files in this subdir)

Edited by JohnWPB
Link to comment
Share on other sites

All I can said is to double check your code. I use DirCopy() to copy my documents into Backups\MyDocs and it copy everything retaining the directory structure . Try the code below and check if you have the same result or not

DirCopy(@DocumentsCommonDir, "C:\Backups\MyDocs", 1)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

All I can said is to double check your code. I use DirCopy() to copy my documents into Backups\MyDocs and it copy everything retaining the directory structure . Try the code below and check if you have the same result or not

DirCopy(@DocumentsCommonDir, "C:\Backups\MyDocs", 1)

Thats pretty kewl with the dynamic directory.

I have checked the code again, again & again, and just getting really frustrated at this point that something so simple is holding me back. I have spent like 3 hours JUST trying to copy a directory INTACT.

Here is a very simple test:

DirCopy("c:\Music\temp", "C:\MP3", 1)

I have 3 MP3 files in the c:\Music\Temp" folder. When I execute the above line of code, it places the 3 mp3's INSIDE the temp folder, into c:\MP3, and is not maintain the directory structure. Someone give this a try them self and please let me know if it is just me. You can stick any ole text files images in the temp folder to test it out.

Link to comment
Share on other sites

Here is a very simple test:

DirCopy("c:\Music\temp", "C:\MP3", 1)

I have 3 MP3 files in the c:\Music\Temp" folder. When I execute the above line of code, it places the 3 mp3's INSIDE the temp folder, into c:\MP3, and is not maintain the directory structure. Someone give this a try them self and please let me know if it is just me. You can stick any ole text files images in the temp folder to test it out.

I just copy all the content of my documents folder into c:\Music\Temp. After running the above script it create MP3 folder and copy all the files and folder structures from Music\Temp folder.

Sorry to give you the bad news, but without the source code I guess we can not help you.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Maybe this is what you are looking for?

#include <file.au3>
Dim $szDrive, $szDir, $szFName, $szExt

$CurrentLocation = "G:\NewMusic\The Doors"  ; No trailing backslash for _PathSplit to add '$szFName'
$FileDestination = "E:\MP3"

_PathSplit($CurrentLocation, $szDrive, $szDir, $szFName, $szExt)
$CopyTo = $FileDestination & '\' & $szFName

MsgBox('', '', '[DirCopy($CurrentLocation,$CopyTo,1)] will be the same as ' & '[DirCopy("' & $CurrentLocation & '","' & $CopyTo & '",1)]')

//udac

Link to comment
Share on other sites

Sorry to give you the bad news, but without the source code I guess we can not help you.

With this problem, it is not necessary to give the TOTAL source to the script here. This is a single line, that needs NO other code to work correctly. I can post the rest of the script, and that is NO problem, but would just be much harder to follow with all the additional code. The bottom line is that the following line DOES NOT WORK:

DirCopy("c:\Music\temp", "C:\MP3", 1)

Using the above, I get a copy of the INDIVIDUAL files in c:\Music\Temp placed into c:\MP3

Resulting in:

c:\MP3

xx1.mp3

xx2.mp3

xx3.mp3

It does not copy the "Temp" folder in any way, and just copies the files in that folder.

I am looking to get:

C:\mp3\temp

XX1.mp3

XX2.mp3

XX3..mp3

I personally am starting to think that this may possibly be a flaw/bug in the AI code. A DIRCOPY "should" copy the directory specified to the new location, and not the individual files in that directory.

Case and point:

A simple:

xcopy c:\temp d:\music

Will end up with the temp directory COMPLETELY being copied to d:\Music which would end up with:

D:\Music\Temp(and all the files that were in the originating temp folder)

It would NOT end up with

d:\Music\ and all the individual files that were in the c:\temp folder, that is currently happening with this command in AI.

A "True" DIRCOPY command SHOULD copy the directory and NOT just the files. This is for all intense purposes a DIRCOPY command and NOT a FILECOPY command.

PLEASE correct me if I am wrong, but this just does not make sense to me in any way...........

Link to comment
Share on other sites

What you should be using is

DirCopy("G:\NewMusic\The Doors", "E:\MP3\The Doors", 1)
oÝ÷ ÙIåzË2¢ìׯz¼­)às^ÀˬȧÂƬzëjëh×6
DirCopy("G:\NewMusic", "E:\MP3", 1)
oÝ÷ Ûú®¢×èu©ìÁêÞvØb±Ê+­ç-,¨»kz
"h«Þ¶^[ay׬¶)Ú¶*'v*ÞrÚ+ÊØ^~]z¹Úéb殶­sdF$6÷gV÷C¶3¢b3#´×W62b3#·FV×gV÷C²ÂgV÷C´3¢b3#´Õ2b3#·FV×gV÷C²Â

Sorry if that isn't how you think it should work, but that's how it appears to work... I tried this using your example and it worked this way. You obviously are able to get your initial folders somehow, if you would post the rest of your code we could probably point out how to concatenate the initial folder into the destination folder to do what you need to.

If you're not happy with the DirCopy command, you could very well use AutoIt to manage the Xcopy command as well.

Edited by exodius
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...