Anyone know of a utility that exists which can traverse a solution file (.sln) and all of its project files and create a zip (archive) of that? My google-fu is failing me on this one, there are too many results showing how to write a program to zip files.
If you have 7zip installed, you can create a batch file to do what you want.
Create a file called archive.bat in the solution directory, open it and add:
"c:\program files\7-zip\7z.exe" a -tzip archive.zip * -xr#archive.ignored
Then create a text file called archive.ignored (in the same location as the .bat file) that lists the filenames/wildcards to be excluded from your archive.zip. For example:
obj
debug
bin
packages
*.obj
*.dll
*.exe
*.zip
*.suo
.vs
archive.ignored
archive.bat
CleanProject almost does what I want, but it doesn't actually read the .sln file so you need to have the relevant projects in the solution folder, and this grabs everything in those folders (cleaning up somethings you wouldn't want in the zip), whether they are referenced in the solution or not.
You should be able to accomplish that by creating a WinZip job. It's a one time setup where you define what, where, and when to create a zip file. I've used it to automate some backup tasks.
Related
I wanted to know how to move files to a .zip archive. I'm using this code: xcopy C:\Folder C:\AnotherFolder\zippedFolder.zip. This copies the files from C:\Folder DIRECTLY into the archive, but I want to have that file in the archive (so i can doubleclick the archive and see the file unopened).
Want to do this to create an excel file with a .cmd
Use -m to import a file to a ZIP archive.
I found this on StackOverflow maybe it helps you.
How to move a file in to zip uncompressed, with zip cmd tool
But be careful it deletes the source file after it adds it to the archive. See the link for more details.
UPDATE
Instructions from this site. http://linux.about.com/od/commands/l/blcmdl1_zip.htm.
-m moves the specified files into the ZIP archive; actually, this deletes the target directories/files after making the specified ZIP archive.
If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without errors. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.
zip -m yourfile zip.file
I would like to be able to copy all files from various folders and combine them into a single folder using a Windows batch file. That is fairly easy to do for me. But if the file already exists on the destination, I would like it to only override the file if it's newer.
copy c:\pics\ to d:\
Thanks.
You can use xcopy for more options if the source dirs are 2-3-5 (write separate xcopy lines for each). If the dirs are too many, you can use archiver like WinRar (or its command line rar.exe) with #list option where are stored the source dirs. In the batch file call RAR 2 times - first to pack all source files to one archive, then to unrar them in single folder (with E option, not X). Finally, you delete the .rar file. See the extra options to skip older files, omit prompts, etc.
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.
I'm working on a visual studio solution with over 30 projects and multiple filters.
What is the easiest way to determine all the projects a file belongs too?
First, open a command shell window and create a list of all project files in a text file. For example, for C# projects (having the ending .csproj), run this command in the root folder of your solution:
dir /s /b *.csproj >projectlist.txt
Then, you can easily determine all projects containing a specific file by the command
findstr /f:projectlist.txt /m Name_Of_Your_File
Just a suggestion: you can avoid much trouble for the future if you make sure each project has it's own folder, and all files belonging to that project are in or below that folder.
Use AgentRansack or similar tool that allows searching text contained in a file.
Use the following settings:
File Name: *.csproj
Containing Text: YourCodeFile.cs
Look in: YourSolutionFolder
Run the search and you will get a list of all project files that are holders of the CS file.
I'm using iexpress to make a self extracting executable. Is there a way I can hard-code an extraction destination folder (preferably into a temp folder somehwere) so as to not have the extraction pop up the "Please type the location where you want to place the extraced file." dialog?
There's no direct way to do this. (You can see my other answer for a longer explanation about it.)
The easiest solution is to make an IExpress archive that runs an "installation program", which is really just a batch file that copies the extracted files where they're needed.
In IExpress, you'd launch the batch file like: cmd /c persist.bat. And persist.bat looks something like:
#echo off
xcopy /y * "%temp%\persistent\"
del /f "%temp%\persistent\persist.bat"
(The last line is a nicety to hide the fact that you used this batch file to copy the extracted archive.)
Yes, this is possible through the use of an .INF file when you select "Extract files and run an installation command". You must set the .INF file as your Install Program and under the DestinationDirs section you would put the path to the directory you want the files to go to. Here is an example of an .INF file:
[version]
signature="$CHICAGO$"
[DefaultInstall]
CopyFiles=install.files
[DestinationDirs]
install.files=-1,"C:\Program Files\MyCustomDir"
[install.files]
MyFile1.txt
MyFile2.bmp
So this sample shows that the installer will install to C:\Program Files\MyCustomDir. The files under the install.files should list all the files you want to copy to that folder. They must be included in your installer when you are selecting the files to add.