• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help me real quick with the DOS "move" command [update: SOLVED]

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Hey Killbat,

Here is something to get your gears turning, I did this in WinNT but I think it is the same in Win2k. Without more details I can't make it more elaborate (by details I mean the names of the files you want to move and the ones you want to keep and how these files get here on a regular basis).

for /f %i in ('dir /b c:\winnt\profiles\blah\desktop') do if "%i" == "Shortcut" echo %i meets requirement


a simple one liner, if you put it in a batch file script the %i's need to be changed to %%i. This will echo every shortcut that starts with Shortcut (case sensitive). I could easily change the Echo to a move statement and make the matching statement more elaborate but I think you get the picture.
 
Jasonh100
"I still want to know how to save the output of a command to a text file if anyone knows."

ie:
c:\> dir /b > dirList.txt

Killbat
Here's a solution for you.

C:\> cd winnt\profiles\user\desktop
C:\winnt\profiles\user\desktop> zip tmp.zip *.* -m -x *.lnk
C:\winnt\profiles\user\desktop> move tmp.zip c:\somebackupdir

zip everything (*.*) into tmp.zip remove original files after adding them to the archive (-m) excluding shortcut files (-x *.lnk).

You can get GNU zip.exe here

Thorin
 
You know, that would work. What of large files, though? I assume you can instruct that archive program to do no compression?
 
Hmmmm well there is an option "-n don't compress these suffixes" that you could make work.

Thorin
 
Try marking the 2 files as "read only" ... that will keep the move program from erasing the original.
 
Yup that would also work if you did:

C:\> cd winnt\profiles\user\desktop
C:\winnt\profiles\user\desktop> attrib *.lnk +r
C:\winnt\profiles\user\desktop> move *.* c:\somebackupdir

Goto desktop.
Make shortcuts read only.
Move everything (resulting in everything moved and copies of shortcuts).

It will only allow copies of the *.lnk files to be made in "somebackupdir".

Thorin
 
"you write the contents of a directory to a file, dir >> test.txt and then...... I don't know, but maybe it helps"

If you use dbl > then you are directing both standard out and standard error to the file. Unless you specifically want the error messages then you only need 1 > .

Edit:
Skace (see below) is correct in DOS > is new file >> is append. I was thinking more like Unix.

"ls > dirLst.txt 2>&1"
Redirect ls output (standard out) to ditLst.txt and redirect standard error to the same file.

Thorin
 
> will overwrite the file
>> will append

so by doing dir >> test.txt you could possibly run it several times and have a log of what was in the current directory each time. but if you only do dir > test.txt it will continually overwrite test.txt

I dunno what was wrong with that sexy 1 liner script I wrote 😛
 
No way, I love these kinds of threads. Dusts out the moth balls and shunts juice through areas of my brain that haven't seen light since the days of DOS/Win 3.1. Ahhhhh. . . therapy 😉

Modus
 
Back
Top