I'm running SourceSafe and I have two branches of my code. I'm currently using the manual approach of running a report to show differences and then manually merging each file one by one. However I'm trying to find a streamlined way to do this on the project level. It's ok if the process shows me each file one at a time, I'm just worried if I go manually one by one to each file and merge each file separately that I'll accidentally skip a file. Whereas a "wizard" I could trust to hit every file even if it shows me each and every file before merging them.
I'm new to merging but not sourcesafe so I guess you could say I'm a half newbie.
Looks like there isn't a built-in way to do this through the UI. But they do provide a command line tool which I ended up writing a batch file for to streamline option specification:
ECHO OFF
SET SSDIR=K:\Archive
SET /P MainProject=Please enter the project to merge into (e.g. "$/Trunk"):
SET /P BranchedProject=Please enter the branched project (e.g. "$/Active Branches/Branch1"):
SET /P Comment=Comment:
SS CP %MainProject%
IF NOT EXIST C:/BranchCheckouts MKDIR "C:/BranchCheckouts"
IF EXIST "C:/BranchCheckouts/mergelog.txt" DEL "C:/BranchCheckouts/mergelog.txt"
SS MERGE %BranchedProject% -GL"C:/BranchCheckouts" -O#"C:/BranchCheckouts/mergelog.txt" -C%Comment% -R
PAUSE
Related
I'm attempting to detect if Python is installed on a Windows system at any given time, while future proofing for updates past 3.10 -- though I assume, of course, that this is reproducible with any file or folder that also has a varying path.
The details
Python doesn't get "installed" the same way others do, i.e. get placed into Program Files (or PF x86) -- it instead gets placed into a user's AppData\Local\Programs\ folder by default. Since my current project relies on the user having Python installed, I want to make sure when the installer shows up that it completed.
The problem arises with that future proofing I mentioned -- Python 3 folders get named after their version, e.g. the folder containing Python 3.10.2 is in AppData\Local\Programs\Python\Python310\, 3.9.9 is in \Python\Python39\, et cetera. I need to check whether python.exe exists or not, but since its directory varies based on version, I also need to check for each folder. However, it occurred to me that there are actually two instances of python.exe past the initial \Python\ folder, one located at the version directory and another deeper in \Lib\venv\scripts\nt\.
The attempts
Currently, I'm attempting to use the method mentioned on this Microsoft Exchange forum post, which explains the following FOR loop could perform a command in each applicable directory;
for /r "<folder one>" %a in ("<folder three or file name>") do #if exist %a <command>
...which I attempted to apply as a simple check (in a standard cmd process, not in a Batch script) with the following;
for /r %userprofile%\AppData\Local\Programs\Python %A in (python.exe) do #if exist %A echo found %~nxA in %~dpA
Because there are multiple matches, though, it returns both paths instead of just the first instance;
found python.exe in C:\Users\<me>\AppData\Local\Programs\Python\Python310\
found python.exe in C:\Users\<me>\AppData\Local\Programs\Python\Python310\Lib\venv\scripts\nt\
The problem
This means I can't simply save %A as a variable and check for it, because by FOR's logic it would save the instance at \Lib\venv\scripts\nt\ and not \Python310\, which is the one I'm looking for specifically. I also can't use if not exist instead, because if I attempt to do so, FOR will act whatever command I use for each of the folders not containing python.exe, which would ignore the fact it does exist elsewhere in the tree.
I attempted to save them both as variables by using /f "tokens=2", but after trying to place it both before and after my /r, I got errors explaining that either "tokens=2" was unexpected at this time" or "%userprofile%\AppData\Local\Programs\Python" was unexpected at this time" -- I'm assuming this is due to the fact I can't use multiple options at once, but it isn't mentioned in FOR's documentation, so I'm not entirely certain.
I also can't simply run where python.exe, as it isn't guaranteed Python will be added to PATH since it isn't checked by default when installing.
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.
I need a way to select several files with check-boxes and drag them all to a batch-file icon. The first step in the script would be to be compressed them into a single zip file before proceeding to the next step. If possible, it would be useful to also end up with each in a separate zip of its own for storage.
I am not sure how to address the for:to commands to allow gathering all selected files into a single zip file in a script. The Windows 'sendto compressed zip' function works perfectly if I select all the files the copy and paste them to the Windows ZF filetype. But I don't know how to access it from within a batch.
Drag and drop multiple files
By default, if you drag a file onto a batch file it is the same as passing the filepath as a parameter. This can be accessed using %%1. Dragging multiple files would have a similar effect and be like calling test.bat file1.txt file2.txt file3.txt. Each "parameter" can be accessed using subsequent variables, %%1, %%2, %%3, etc, up to %%9.
Get more information here.
Zipping files
First you will need a utility that supports command line operations, such as 7-zip. Once you have the appropriate executable in your path, you will need to review the documentation on how to zip files from the command line. Instead of using the paths and filenames, you will use the variables mentioned above.
Here is some pseudo code:
zipfiles output.zip %%1 %%2 %%3 %%4 %%5
Notes
You will not be able to drop more than 9 files.
You may need to confirm that each variable exists. If you try to include %%9 in the zip command but you only dropped 8 files, you may get an error.
I would like to update a line in a few different batch files at the same time.
How would I go about writing something to change multiple identical lines in a file.
Specifically, every week I have a BAT file create a new folder labeled "Week monthdayyear"
I have other BATs that have been made to move files to that new folder throughout the week. Currently the only thing I know how to do is manually change the date in each of the BATs that move files to that folder every week. I would like to have my BAT file that creates the new directory to modify the other BATs and input the new directory.
Example:
Each Bat Contains:
ren "...\Week 4-13-2015\..."
I need to change each bat to say
ren "...\Week 4-20-2015\..."
This question is related to another question I asked a week ago. I solved the other question if you want to use it as reference for more background information and the actual scripts.
Can a Batch File Tell a program to save a file as? (If so how)
You have a problem of inter-program communication, that is, the program that create the new folder every week needs to inform to the rest of programs the name of the current folder. You may do that via an auxiliary data file. For example, include this (or similar) line in the program that create the folder:
echo Week %monthdayyear%> CurrentWeek.txt
... and get the right name in each one of the rest of programs:
rem Get the name of the current folder
set /P currentFolder=< CurrentWeek.txt
. . .
ren "...\%currentFolder%\..."
I'm building an application that has quite a few files that need to be included in the destination directory. So far, there haven't been very many files so I would simply change the settings of each file individually to Copy to Output Directory :: Copy if newer. The problem now is that I'm adding files at an exponential rate.
Do any of you know how to make all of the files that are sub of the "Some_Directory" have the Copy to Output Directory :: Copy if newer set how I want it?
You cam use a post-build event.
Using following posts, I made a post event that does exactly what you want:
Copying files into the application folder at compile time
Copy to Output Directory copies folder structure but only want to copy files
Visual Studio adds .dll and .pdb to project after compiling
Now, you can easily edit Post-build events, go to your project settings and go to the Compile tab, now click the Build Events and put following line in the *Post-build event command line" text box:
xcopy "$(ProjectDir)Test\*.*" "$(TargetDir)Test\\" /E /I /F /Y
See this image:
In your case you will have to change "Test" by "some_directory" and that's all.
There is one caveat, however. This copies every file every time my project builds. The folder that is being copied is over 3MB (I'm developing quite a large project). This makes debugging take quite a long time because every time I do a build it has to move all of the content over. Is there a way to make it only copy over files that have been updated since the last build? This is why I was using the Copy if newer option.
You can add the /D parameter (you can look that up with xcopy /? in your command prompt).
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
You can write your own custom Post-Build event (Select project -> Properties -> Build Events) with xcopy command. You can use $(solution) macro for your solution directory and specify relative path to your files.
I had the same issue, but the accepted answer didn't solve it. What worked for me was to enable deployment in Local.testsettings (under Solution Items).