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.
Related
We're sharing SYMLINKD files on our git project. It almost works, except git modifies our SYMLINKD files to SYMLINK files when pulled on another machine.
To be clear, on the original machine, symlink is created using the command:
mklink /D Annotations ..\..\submodules\Annotations\Assets
On the original machine, the dir cmd displays:
25/04/2018 09:52 <SYMLINKD> Annotations [..\..\submodules\Annotations\Assets]
After cloning, on the receiving machine, we get
27/04/2018 10:52 <SYMLINK> Annotations [..\..\submodules\Annotations\Assets]
As you might guess, a file target type pointing at a a directory [....\submodules\Annotations\Assets] does not work correctly.
To fix this problem we either need to:
Prevent git from modifying our symlink types.
Fix our symlinks with batch script triggered on a githook
We're going we 2, since we do not want to require all users to use a modified version of git.
My limited knowledge of batch scripting is impeding me. So far, I have looked into simply modifying the attrib of the file, using the info here:
How to get attributes of a file using batch file and https://superuser.com/questions/653951/how-to-remove-read-only-attribute-recursively-on-windows-7.
Can anyone suggest what attrib commands I need to modify the symlink?
Alternatively, I realise I can delete and recreate the symlink, but how do I get the target directory for the existing symlink short of using the dir command and parsing the path from the output?
I think it's https://github.com/git-for-windows/git/issues/1646.
To be more clear: your question appears to be a manifestation of the XY problem: the Git instance used to clone/fetch the project appears to incorrectly treat symbolic links to directories—creating symbolic links pointing to files instead. So it appears to be a bug in GfW, so instead of digging it up you've invented a workaround and ask how to make it work.
So, I'd better try help GfW maintainer and whoever reported #1646 to fix the problem. If you need a stop-gap solution, I'd say a proper way would be to go another route and script several calls to git ls-tree to figure out what the directory symlinks are (they'd have a special set of permission bits;
you may start here).
So you would traverse all the tree objects of the HEAD commit, recursively,
figuring out what the symlinks pointing at directories are and then
fixup the matching entries in the work tree by deleting them
and recreating with mklink /D or whatever creates a correct sort of
symlink.
Unfortunately, I'm afraid trying to script this using lame possibilities
of cmd.exe-s scripting facilities would be an exercise in futility.
I'd take some more "real" programming language (PowerShell as an example,
and—since you're probably a Windows shop—even a .NET would be OK).
I am trying to get a directory listing of only files with a given extension. At first blush this seems to be a simple thing to do, however check out this simple example:
C:\CODE\metcal>dir /b *.exe
metcal.exe
metcal.exe1
Notice that this returns metcal.**exe** and metcal.**exe1** as matches.
With python files a similar thing happens:
C:\CODE\metcal>dir /b *.py
metcal.py
metcal.pyc
Notice again Windows has determined that *.py takes anything that starts with *.py so it captures the .pyc files as well.
Is there a way to get only the extensions that match exactly? In the above python files example I would like the following to occur (obviously with the correct syntax substituted for *.py)
C:\CODE\metcal>dir /b *.py
metcal.py
As a note the matching under Windows not as simple as it seems.
*.exe matches foo.exe, foo.exe1, foo.exeabcde but not foo.exe.bak
There are other questions on SO that are similar that are related to long/short file names. The *.py and *.pyc example here should not introduce name mangling machinery.
**I have experimented on XP and Win7 machines and this behavior is not consistent at the cmd Prompt and file open dialogs. This inconsistant behavior makes me suspect this problem is related to settings of somekind. **
It's because windows wildcards on extensions check both long and short names as explained in this answer:
https://superuser.com/questions/238900/winxp-dir-command-3-and-4-char-extensions-are-the-same#238930
Solution there is to disable 8.3 names creation and then striping them on ntfs volumes which will also improve performance.
Microsoft Docs: Fsutil 8dot3name
Remarks:
Permanently removing 8dot3 file names and not modifying registry keys that point to the 8dot3 file names may lead to unexpected application failures, including the inability to uninstall an application. It is recommended you first back up your directory or volume before you attempt to remove 8dot3 file names.
So if you want to get only those extensions (.py and .pyc), you should try like this way :
#echo off
dir /b *.py*
pause
You can use the Unix ls command from the Windows Subsystem for Linux to do this, assuming you have WSL installed. It's freely available from Microsoft. From your Windows command prompt, type wsl followed by the ls command to list the files you want.
So, for your example, wsl ls metcal.py returns only metcal.py. To get the same results as you're seeing with dir, use wsl ls metcal.py*.
Search files through case sensitive extension on the Windows command line. I want the search a list of jpg files in my directory where some files has extension xxx.jpg and some yyy.JPG .
Here I want the list of all files who has extension yyy.JPG
Any help.
Thanks in advance
dir *.jpg|findstr /e /L ".JPG"
shoud deliver that list; only when the end of the lines literally match the string will findstr allow the line through.
command.com doesn't care about case, but the DOS API does pay attention. So, writing a simple DOS program to search the files will allow you to match what you want.
You can also use most other programming languages (even BASIC!) to get a directory, and it will take you literally. You could even get what you want by getting a directory listing from command.com and then piping it through the find command:
dir | find ".JPG"
Since you asked this on Stackoverflow (programmer's site) it's assumed you want to write a program. If not, youll want to try superuser.com instead.
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.
As per the answer to this question, I am trying to backup a file by renaming it, before I replace it with a new, modified file with the old name.
As per the comments and the documentation here, I am using the following line of code:
File.rename(File.basename(modRaw), File.basename(modRaw)+'.bak')
However, when I do so, I get the following error at runtime:
The program then aborts. (leatherReplacer.rb is the name of my program, and line 88 is the above line of code)
How do I allow my program to rename the files it needs to to run successfully?
Windows has some special rules regarding permissions. The important one at work here, is that the OS prevents moving or renaming a file while the file is open.
Depending on the nature of your code (in size and scope) and the importance of the file you're trying to back up, it may be unfeasible or otherwise not worthwhile to refactor the code in such a way as to make backups possible.
You probably don't want to be calling File.basename in there, that strips off the directory:
Returns the last component of the filename given in *file_name*, which must be formed using forward slashes ("/") regardless of the separator used on the local file system.
So, if modRaw is /where/is/pancakes.house, then you're saying:
File.rename('pancakes.house', 'pancakes.house.bak')
But pancakes.house probably isn't in the script's current directory. Try without the File.basename calls:
File.rename(modRaw, modRaw + '.bak')
If you are owner of that file, use File.chmod to set desired permissions.
I don't know much about ruby, but could you run it under command line/bash with admin privileges, such as "run as administrator" or "su root"?
According to Objectmix and ruby-forum, you should set it to 755 or +x, then perhaps chown to yourself.
try using full file path e.t
File.rename('c:\pancakes.house', 'c:\pancakes.house.bak')
in win7 i encounter same problem