Jump to content
Sign in to follow this  
Everyone

DirMove() fails with %systemvar%-type folders

Recommended Posts

Everyone

I'm making an app that will move files from user's profile into a new structure. To work properly, it needs to read the current folder structure from registry. The problem is that DirMove() doesn't understand stuff coded in system/environment variables like %USERPROFILE%, %USERNAME%, etc. and default shell folders' structure is written in registry keys using those variables. Is there an easy way to get around this, or should I fall back to xcopy?

Edited by Everyone

[size="1"]Reset! Reload! Revolution![/size]

Share this post


Link to post
Share on other sites
Authenticity

Add this to the top of the script:

Opt("ExpandEnvStrings", 1)      ;0=don't expand, 1=do expand

Share this post


Link to post
Share on other sites
Everyone

Thanks :)


[size="1"]Reset! Reload! Revolution![/size]

Share this post


Link to post
Share on other sites
Everyone

I got another problem :) it seems that DirMove() doesn't continue moving files after encountering a file that it cannot move and just gives up for the rest of them. It doesn't even copy them. Any chance of resolving this problem without having to write a function of my own or searching for some UDFs which still would have to be tested and eventually implemented? I'm messing with that move-files-thing a long time now and I would already publish the app if it wasn't for this showstopper ;)


[size="1"]Reset! Reload! Revolution![/size]

Share this post


Link to post
Share on other sites
Authenticity

Read the function remarks. Maybe DirCopy is more appropriate with your case.

Share this post


Link to post
Share on other sites
Everyone

Not really. The thing is that I'm trying to move data from user shell folders to folders chosen by the user. For example, here are some registry keys with their corresponding values:

Personal = [...]/UserX/Documents

My Pictures = [...]/UserX/Documents/My Pictures

My Music = [...]/UserX/Documents/My Music

They need to be moved to

[...]/UserY/Docs

[...]/UserY/Docs/Pics

[...]/UserY/Docs/Tunes

If just DirCopy Documents, My Pictures and My Music, their data will be put into right places BUT as a side effect, folder Docs, while having folder Pics and Tunes will now also have unwanted redundancies in form of My Pictures and My Music folders. If I put all paths in an array, sort the array descending, and then move folders one after another, this side effect won't happen and even if it will, it won't happen very often and redundant folders won't have much files inside them. Of course some system-locked files cannot be moved, but IMO the function should just skip'em.

Besides I think that DirCopy will fail in the same manner - as soon as it encounters a file that it cannot copy, it will just quit.

Edited by Everyone

[size="1"]Reset! Reload! Revolution![/size]

Share this post


Link to post
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
Sign in to follow this  

×