Copy All Files and Directories & Subdirectories in SAS - dos

I used the follwoing statement to copy over files from one folder to another... but it does not copy over the subdirectory (and the files and folders under that subdirectory)
%sysExec copy "&driv.\&path1\*" "&driv.\&path2";
Any Solutions?

I don't think this is a SAS question. This would depend on your enviroment.
If you are on Windows, try xcopy
If you working in another environment, post additional info

I usually use a FILENAME PIPE for this, and then execute through a data step. The standard output is then captured in the data step. I've not got SAS available at the moment, but it would look something like this:
filename mycopy pipe """xcopy "&driv.\&path1\*.*" "&driv.\&path2\""";
data copydir;
infile mycopy;
input;
stdout=_infile_;
run;
You can check the data set's STDOUT variable for feedback on what happened.
If you're still running into trouble, then test the command you're running from the command line first and then transfer to your SAS code.

Try this . . .
%sysExec xcopy "&driv.\&path1\*.*" "&driv.\&path2\*.*" /s;
The /s option copies all subdirectories - provided they are not empty.

Related

Shell script to copy and paste a particular file from one directory to another?

As part of a Windows software project I'm working on I need to copy and paste a particular DLL file from directory A to directory B. In the process, I need to overwrite any previous version of this file in directory B.
Directory A is: Documents/Visual Studio/2015/Project/MyProject/MyProject/bin/Debug
Directory B is: This PC/Windows(C:)/Users/Public/Public Documents/B
Is there a shell script that can perform this operation?
Any help would be greatly appreciated!
Described goal can be achieved by single cmd command:
copy /Y "%USERPROFILE%\Documents\Visual Studio\2015\Project\MyProject\MyProject\bin\Debug\libName.dll" "C:\Users\Public\Public Documents\B"
So you can put this command into scriptName.bat file and execute. Put pause at the end of the file to prevent window closing if you want to check script output.

MKS integrity client get folder structure

I have a project folder in integrity client from which I want to get the entire folder structure. This folder structure should have all the folders and subfolders but no files inside. I don't even know this is possible or not.
I want this to run from command line. Any suggestion from UI perspective is also fine. Thank you.
I don't think this can't be achieved with only one command;
my suggestion is to createa a small script or batch, where you will use the SI VIEWPROJECT --RECURSE command and filter out the lines not ending with ".pj" (subprojects)
Not sure if I'm much too late, but I just stumbled across your question.
You could use the following command (simply type into Windows command line) to inventarize a downloaded sandbox:
$ TREE /F <path to Sandbox>
So in my case it'd be:
$ TREE /F D:\Sandbox\Name
You could even guide the output into a .txt file and postprocess it from there...
$ TREE /F D:\Sandbox\Name > D:\Output.txt
Edit: You would still have to take out all the filenames afterwards in your favourite programming language of choice (just check for the dash characters in front of folders and delete everything else...)
You can use the si viewproject command with filter by name activated to get only subprojects.
si viewproject --hostname={SI_HOST} --port={SI_PORT} --project={Project_Path} --filter=attribute:name=project.pj -R
Depends on your server configuration, the project.pj can be different.

Windows batch autoanswer XCOPY /i

I have created a batch file which uses FOR command to read a file of FROM Directory, FROM File, TO Directory, TO File as the parameters. (I am giving the files NEW names in the destination)
Everything works great until I add a new file to the mix.
In XCOPY /i option says it is a directory (which is NOT true). IF I don't use /i it wants to know if it is a file or a directory. It is ALWAYS a File. Is there a way I can autoreply or does someone have another suggestions.
echo f|xcopy [options] [files*]
A short investigation did not yield an easy command line parameter solution.
If I got you right, you are trying to copy a file from one directory to a new directory + give it a new name in the new directory. Copying to the new directory should work fine when you terminate target directory name with a tailing '\' (backslash) - this should result in a file with the same name in the target dir. Renaming this file to the new name will be straight forward. However, it's two commands instead of one...
In case this does not work for you: maybe you can illustrate your qn with a sample / snippet of the batch file?

Renaming files that start with

I've created a batch script to automatically update some files using wget for Windows. It downloads a file with a version number in the filename, for example server-2.0.exe. I want to automatically rename the file to server.exe.
I think that wget has the option directly in its commands.
--output-document=file
This might do what you want, depending on how variable the filenames are:
ren C:\server*.exe server.exe
Try this:
ren server????.exe server.exe

DOS Commands- Excluding files in a folder in xcopy

I have a folder containing many other sub-folders.
I am trying to write a batch file which will copy some of the folders to another place on my hard disk. I am using "xcopy" for this. I am facing following problem:
The folder structure is as shown below-
--FolderB1
---FolderB2
---FolderB22
---File1.txt
---File2.txt
---File3.txt
I have some .txt files inside "FolderB1", along with "FolderB2" and
"FolderB22" I want to copy "FolderB2" and "FolderB22" and skip ".txt"
files contained in "Folder B1"
I tried using /EXCLUDE: param of xcopy command, but it is not able to perform this operation. It does not work if I specify the exclusion as \FolderB1\*.txt or something of this sort.
The number of main folders is not known. It can be anything. Also, there is no fix pattern for names of ".txt" files. Have checked this question too, but did not help.
Alternate method or other pointers for the same would be a great help. Thanks in advance.
What you could try to do is to hide the files you don't want to copy, then execute the xcopy, and then unhide the files again.
Look at my answer of question Windows batch script to delete everything in a folder except one. That question was related do deleting files (excluding some files), but you can probably use the same trick for xcopy-ing files.

Resources