Export from Source Safe - export

Is there a way to export files/folders from Source Safe? (i.e. getting rid of all .scc files, just like SVN export)

Just do a regular get, then run something like
ATTRIB -R *.scc /S
DEL /F /S /Q *.scc
The first command removes the read only flag from those files. The second deletes everything that matches *.scc along the path.

Related

How to extract part of a string using only variables in a batch file?

Maybe I'm trying to oversimplify things. Having trouble removing part of a variable to be used as a path name. Goal is to transfer everything from folders (and sub) on multiple windows profiles to a single profile.
I can copy all the content, but cannot tell it where to place it. Also happen to be trying to use robocopy instead for the first time. I want to make a folders on the desktop that are named the username of every user on the device, then copy all content.
for /d %%a in (C:\Users\*) do (
set var=%%a
var=${var#*s/ }
mkdir "%USERPROFILE%\Desktop\Backup\%var%\folderx"
xcopy "%%a\Desktop\folderx" "%USERPROFILE%\Desktop\Backup\%var%\folderx" /E /Y
)
Notes:
Not sure the best way to remove C:\Users\ so I leave just the username as a variable (it assumes var is a command)
I'm trying to do it without having to write a string to file and read it back
This assumes the Backup folder is already created
Still not sure how to strip it correctly. Just found it more efficient to not include the drive in the first place.
List item dir bare command to get name
changed C: to user variable in case installed on a different letter
FOR /f "tokens=*" %%a in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
mkdir "%USERPROFILE%\Desktop\Backup\%%a\folderx"
mkdir "%USERPROFILE%\Desktop\Backup\%%\foldery"
xcopy "%SystemDrive%\Users\%%a\Desktop\folderx" "%USERPROFILE%\Desktop\Backup\%%a\folderx" /e /y
xcopy "%SystemDrive%\Users\%%a\Desktop\foldery" "%USERPROFILE%\Desktop\Backup\%%a\foldery" /e /y
)
Strictly speaking, not an answer, but a cleaner solution to the root problem. Still not sure how to properly strip information.

Odd behavior with the DEL command

Was writing a short script to search out all files with a certain extension, rename them and delete them... but I noticed some odd behavior in the delete script.
Let's say I have four files: file.lo, file.log, file.logs, & file.logarithm
If I use the command del /s /q /f *.lo then only file.lo is deleted. If I use the command del /s /q /f *.logs then only file.logs is deleted.
But if I use the command del /s /q /f *.log then .log, .logs, and .logarithm are deleted. The only file that remains is file.lo
Can anyone explain this behavior?
Explanation: file.logarithm matches the 8.3 short name file.log
Workaround: del file.log.
According to this answer, using an extension of exactly 3 characters in a search pattern causes the search to also return matching files with longer extensions, and otherwise allways finds exactly the right files. You should apparently use "file?.log", "file.log." as Stephan suggests, or one of these suggestions

How to delete all files and sub-folders in a folder except for 1 folder in a .bat script?

I have a folder that stores many log files and sub-folders. I would like to delete all files and sub-folders except 1 folder, named Excel_Export, which should not be deleted. I am using the following commands in my batch script:
move D:\ABC\Delete_Test\Retain_Folder D:\ABC
rd /s /q "D:\ABC\Delete_Test"
move D:\ABC\Retain_Folder D:\ABC\Delete_Test
However, after this script runs, even the 'Retain_Folder' is getting deleted except for the files inside it. What is it that I am doing wrong in the above command?
Also, is there a better way to do it?
NOTE:
All the other folders' names (that are to be deleted) starts with the '$' symbol.
This is untested - it deletes all normal files in d:\abc and then removes all folders beginning with $ in the same folder.
#echo off
del "d:\abc\*.*?"
for /d %%a in ("d:\abc\$*") do rd /s /q "%%a"
Your idea is probably the most efficient (fastest) way to accomplish your task, except you have one small bug. Your RD command removes the Delete_Test folder, so you must recreate it before you can move Retain_Folder back to where it belongs. You also probably want to redirect output to null when you move the folder - you don't need to see the move message.
move "D:\ABC\Delete_Test\Retain_Folder" "D:\ABC" >nul
rd /s /q "D:\ABC\Delete_Test"
md "D:\ABC\Delete_Test"
move "D:\ABC\Retain_Folder" "D:\ABC\Delete_Test" >nul
This strategy only works properly if you know that D:\ABC\Retain_Folder does not already exist before you start, or if it does exist, then it must be empty.

Assistance modifying a batch file to delete the C: drive

Newbie question.
Would cd "C:del *.* delete all files within the C: drive?
I was also told if I add del . /F /Q it would bypass confirmation of the deletion, but I'm not 100% sure where to put it. Do I just add it onto the end like
cd "C:del *.* del . /F /Q?
This is a dangerous command. Be careful.
No, you probably want del /F /Q ..
The first part, del, is the command. This is telling it to delete something.
/F /Q are the options, denoted by the leading slash.
/F means to force it, so for example if a file isn't writable it will still delete it if able. It also skips some other checks.
/Q tells the program to be 'quiet', so less output will be generated than normal
.(dot) is the thing to delete, which is the place you currently are. If you are currently in C:\ (ie if the terminal displays C:\> at the beginning of every line), then it will be that that it deletes.
Note that I have only shown what you should type (del /F /Q .) and not what the entire line should look like when you're done (C:\> del /F /Q .). However, if this is going in a batch file then you want the first form only.
This is a destructive command and is provided merely to answer the query - don't try it at home or prank friends with it.
This will delete all files that are not locked, or opened for exclusive access by a program.
del c:\* /s /f /q /a
It will not delete every file in a Windows system drive and will not remove directories.

xcopy does not create directory structure

I have a strange problem with xcopy in Windows XP Professional. I don't know if its a stupid question as I am specifying only a file as the source, so should I even expect any other behavior ? This is it:
I am using xcopy <src> <dest> /s/y.
<src>=C:\sourcefolder\a\b\c\d\something.java and
<dest>=C:\destinationfolder.
Now xcopy copies the file but does not create the directory structure \a\b\c\d\ inside C:\destinationfolder .
what I want is C:\destinationfolder\a\b\c\d\something.java and
what I get is C:\destinationfolder\something.java
I have tried to run it in destination folder C:\destinationfolder by specifying a . for target folder
Tried it without any target in above
There is a script I have which calls xcopy iteratively so I am left with C:\destinationfolder\many java files without any directory structure.
A. Yes I have done xcopy /? to see all options
B. /T also does not create any empty directory structure
C. I can not go to source folder a\b\c\d\ and run xcopy . <dest>
UPDATE
I removed my previous answer on using ROBOCOPY. I believe the following will do what you want using XCOPY.
Assuming your folder structure is like this:
SOURCE = C:\MyJavaStuff\A\B\C\D\something.java
DEST = C:\MyDestination
Run XCOPY like this:
XCOPY C:\MyJavaStuff\something*.java C:\MyDestination /S /E
Note the * in something*.java.
The problem is that you are specifying which file to copy in the source. xcopy won't create the folder structure in this case. However, if you change your call to xcopy to
xcopy *.java C:\myfolder /s/y
it will copy the .java files and the folder structure as well. You need to specify a wildcard for this call to work as you want. If you want only to copy specific files, you will have to adjust the call to xopy, e.g.:
xcopy something.jav* C:\myfolder /s/y
Edit
You say that you get the list of files to copy from another command. If you can output this list of files in a text file, you could do the following:
FOR /F "tokens=* delims=," %F in (d:\test\list.txt) DO xcopy src\%~nxF* .\dest /S /Y
What this command does is read a text file ("d:\test\list.txt" in this case), read every line, and for each file, run xcopy, adding a wildcard at the end of the file name to make sure it creates the folder structure.
I'm assuming here that:
You can get the list of files in a text file, with only the file names (and optinally the paths)
You know the source folder ("C:\sourcefolder" in your example, the folder structure "a\b\c\d" does not need to be known) and can use it in the FOR command.
You can also use the following form:
FOR /F "tokens=* delims=," %F in ('cmd') DO xcopy src\%~nxF* .\dest /S /Y
where cmd needs to be replace with the command you use to generate your list of files to copy.
Note that if you use this FOR command in a batch file, you need to replace %F with %%F (and %~nxF* with %%~nxF*).
I had a look at the xcopy switches and you can copy the directory structure with /T, although that doesn't copy empty directories you can override this with /E. So your command would look like this:
xcopy C:\sourcefolder\a\b\c\d\something.java C:\destinationfolder /T /E /S /Y
Hope this helps!
In order to get C:\destinationfolder\a\b\c\d\something.java XCOPY needs to know how much of C:\sourcefolder\a\b\c\d\something.java to duplicate.
You can use:
C:
cd \sourcefolder
XCOPY something.java* C:\destinationfolder\ /S
Just be aware that this may have the side effect of also copying C:\sourcefolder\oops\something.java to C:\destinationfolder\oops\something.java as well as any other matches for something*.java under C:\sourcefolder\.
It seems to me that xcopy is typically used for copying directory trees, not single files (though it can work). And, xcopy will recreate the directory structure under the source folder in the target folder. If xcopy is given the /i switch, the target folder is assumed to be a directory. It will be created if it does not exist, even if there are multiple parents that need to be created.
You have C:\MyJavaStuff\A\B\C\D\something.java - that is your source. You want to end up with something.java not in C:\destinationfolder, but in C:\destinationfolder\A\B\C\D - so that is your target. You don't even have C:\destinationfolder. That is OK, with /i the entire path will be created.
xcopy /i c:\MyJavaStuff\A\B\C\D\something.java C:\destinationfolder\A\B\C\D
If something.java were the only file under C:\MyJavaStuff, you could also use
xcopy /sei c:\MyJavaStuff C:\destinationfolder
That would recreate the entire tree structure, copying your file. But if there are other files (and folders) under MyJavaStuff they would also be copied.
I have written a very similar batch file using xcopy. Perhaps what I did will help you.
This is the command I used:
xcopy "c:\Data Files\Dave's Data\*.*" "m:\Dave's Data" /R/D /E/H
In this case, Dave's Data on the source contains an entire directory tree containing at least 50,000 files & exceeding 75GB data. It runs perfectly on Windows XP
I found /T was unnecessary as the directory tree is copied. I also found /S was unnecessary as /E copied directories & sub-directories including empty ones. I included /R to copy & overwrite read only files on the destination. /H copied hidden directories. /D copied only newer files. I use this as a daily backup tool for my data.
The only problem I have is while this command will work on Windows 7 the first time, it will not work on subsequent runs when the destination directory tree exists. I suspect this is due to a privilege issue as the xcopy command will work on subsequent runs on Windows 7 within a cmd.exe window.

Resources