Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,863 of 42,547    |
|    Gleep to foxidrive    |
|    Re: moving all files and folders into a     |
|    17 Dec 13 20:46:09    |
      From: erik.tank@gmail.com              On Tuesday, December 17, 2013 7:31:58 PM UTC-6, foxidrive wrote:       > On 18/12/2013 11:32, Gleep wrote:       >        > > I'm trying to figure out a way to move all of a user's files and put them       into a subdirectory currently in their own folder.       >        > >        >        > > Example:       >        > > C:\Data\User1\*.* moved to C:\Data\User1\files\*.*       >        > >        >        > > I need to retain completely directory structure (empty folders, as well as       folders and files with spaces in their names).       >        > >        >        > > This seems like such a simple task, but I'm almost out of hair... maybe       I'm missing something?       >        > >        >        > > Thanks in advance!       >        > >        >        >        >        > Use xcopy to copy them all to a folder in c:\data and then move the folder       into c:\data\user1\files after       >        > the xcopy.       >        >        >        > This will stop the error message from xcopy.              Thanks for the xcopy tip - I thought about using this first, but xcopy doesn't       MOVE files, it copies them. In this instance, I do not want to make a copy,       as it is over 1TB of data between all our users, not to mention the time it       takes to copy        something vs just moving it.               What I've done so far is fumbled my way through making a script which parses       the user's directory and saves it to a file (all the files, folders, and       subfolders). Then I use a for statement to move each file into the "files"       subfolder.               The first problem I had was once the "files" subdirectory was created, it       started moving the "files" folder that already had data in it to another       subfolder "files" almost like an infinite loop scenario. For that, I am using       the findstr /V command to        filter out the "files" folder and only move data that doesn't belong to that       directory.               Right now this script ALMOST works - the problem I am having is any folder or       file with a space in it gets skipped and an error pops up about the file not       existing (because it's only trying to copy the file up until the space, not       using the whole        filename). For this, I tried adding another for statement which adds double       quotes at the beginning and end of each line in my findstr output file, but       even when I watch the script run - It has quotes around it, but sadly only       takes it up to the first        space and then cuts off the other quote.               Here's my script. I enter the bat file's name followed by the username (which       gets passed as %1 value). At the end I move the list directory back to the       root folder so I can see what data should have been moved.              dir C:\dfs_shares\home\staff\%1/s/b | findstr /V /R /I /C:"\files"       /C:"\cache" >"C:\dfs_shares\home\staff\%1\@movelist"       for /f "tokens=*" %%a in (C:\dfs_shares\home\staff\%1\@movelist) do echo       "%%a">>"C:\dfs_shares\home\staff\%1\@movelist2"       pause       mkdir C:\dfs_shares\home\staff\%1\files       for /f %%f in (C:\dfs_shares\home\staff\%1\@movelist2) do move %%f       c:\dfs_shares\home\staff\%1\files\       move C:\dfs_shares\home\staff\%1\files\@movelist C:\dfs_shares\h       me\staff\%1\@movelist       move C:\dfs_shares\home\staff\%1\files\@movelist2 C:\dfs_shares\       ome\staff\%1\@movelist2              The second for loop in my code is the problem. It is not parsing an entire       line, it is parsing the first glob of text - as soon as it hits a space, it       returns that value instead of taking everything in the quotes as one value.              If you (anyone) knows how to fix that so my second for loop pulls in a whole       line of text instead of up until the first space, I think that would solve my       problem!               Thanks again!              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca