I have a very complex web app project I want to re-structure. Naturally, it consists of a considerable number of folders and sub-folders. I have a huge piece of paper ready to sketch a new structure on.
Now, I need paper printouts of the projects. Some directories I need in full detail including their files - the /library directory for example that contains core parts of the engine. Other directories, I need in much less detail, with just the sub-directories, or not even that.
I am on Windows and can use the tree command but that only gives me a full listing of the whole structure I then have to clean up by hand. I would much rather have a tool which I tell which directories I need in which depth, and in which I can save those settings.
Does anybody happen to know such a tool?
Edit: I have kind of sorted it out using the tree command, deleting the entries manually. To get what I wanted I would probably have to write a script of my own, which I can't do right now. Any hints are still welcome.
I would use a bit of Powershell code for this
Take a look at this example and look at the help page for getChilItems (gci).
You can specify files to include and files not to include.
$DllFiles = gci "C:\Windows\System32" -recurse | ? {$_.extension -eq ".exe"}
Foreach ($Dll in $DllFiles) {
$Dll.name + "t " + $DLL.CreationTime + "t " + $Dll.Length
$i++
}
Write-Host The total number of files is: $i
Here is an example of the exclude parameter
Get-ChildItem c:\scripts*.* -exclude .txt,.log
there is also an include parameter is that fits your needs better.
Are you wanting a batch file/folder renamer? Or something that lets you export the tree to a CSV or XML, or do you want to just see the files you want in the tree?
I used to use a program called FileMonkey, but it hasn't been updated since 2005. A quick search for the latest and greatest batch file handler turned up a few, the one I liked is Flex Renamer.
Apoligies if you've already tried this - I have no idea of your level of Linux knowledge.
Sounds like you may want to use find. It can find everything under a certain path with
find /path/to/directory/
or it can find just directories with
find /path/to/directory/ -type d
Using either approach, you can redirect the output to a file
find /path/to/directory/ -type d >> output.txt
find /path/to/somewhere/else/ >> output.txt
and then edit the file as you see fit.
Hope that is helpful.
-Jim
Related
I am organizing a large Windows folder with many subfolders (with sub folders, etc...), in which files have been saved multiple times in different locations. Can anyone figure out how to identify all files with duplicate names across multiple directories? Some ways I am thinking about include:
A command or series of that could be run in the command line (cmd). Perhaps DIR could be a start...
Possibly a tool that comes with Windows
Possibly a way to specify in search to find duplicate filenames
NOT a separate downloadable tool (those could carry unwanted security risks).
I would like to be able to know the directory paths and filename to the duplicate file(s).
Not yet a full solution, but I think I am on the right track, further comments would be appreciated:
From CMD (start, type cmd):
DIR "C:\mypath" /S > filemap.txt
This should generate a recursive list of files within the directories.
TODO: Find a way to have filenames on the left side of the list
From outside cmd:
Open filemap.txt
Copy and paste the results into Excel
From Excel:
Sort the data
Add in the next column logic to compare to see if the current text = previous text (for filename)
Filter on that row to identify all duplicates
To see where the duplicates are located:
Search filemap.txt for the duplicate filenames identified above and note their directory location.
Note: I plan to update this as I get further along, or if a better solution is found.
I want to simplify Visual Studio Find in Files result, and I found a posting.
And I found it is not quite satisfactory.
Is there a way to display partial portion of directory in find result window?
ie)
x:\users\myname\project\solution_home\project1_home\src\project1.cpp
x:\users\myname\project\solution_home\project1_home\src\helper.cpp
x:\users\myname\project\solution_home\project2_home\src\helper.cpp
into
\project1_home\project1.cpp
\project1_home\helper.cpp
\project2_home\helper.cpp
IMHO, filename alone is not enough to distinguish important result, particulary in large soultion.
but, I want to eliminate certain part of directory path being repeated in every single result.
I wish there would be directory depth designation in $d format string.
ie)
$0d : file's directory
$1d : parent directory
$2d : parent of parent
... etc
Is there any extension and/or technique to do this?
PS: sorry for my poor english
I have something of a hack for this problem: map the local path to a drive. For example:
> subst Y: x:\users\myname\project\solution_home
Your Find Results will then be:
Y:\project1_home\project1.cpp
Y:\project1_home\helper.cpp
Y:\project2_home\helper.cpp
N.B. It has the side effect of breaking the CodeLens Team indicators (which must be a bug).
So, is there a possible way to move Test.txt to C:\ProgramData\CsD2\Tools\("Unknown Folder Name")\data\per Using command prompt?
using foxidrives solution for your previous question for detecting the correct directory, then just
move test.txt "%folder%\"
Short answer: yes. Not quite sure what the situation is that has left only the middle part of your path unknown, and the need to use the comnand line, but I have encountered similar cases on Linux and expect the algoirthm can be adapted to Windows commands. It's possible to do this by hand rather than writing a shell script, but it's up to you and your skills.
Permissions matter. Make sure you elevate yours enough to read and write in Tools before continuing.
First, change directory to C:\ProgramData\CsD2\Tools\
Presumably there are many items here. Some may be "hidden," so list the contents of this directory and be sure to include an option to show hidden files and folders. If you can, restrict the search to directories only.
It's tempting to display contents recursively in the above step. It's up to you, but I find it makes the output cluttered without a script to do the rest of the work.
Now it's time to search for the subfolder set that theoretically only exists in your target folder. Suppose Tools contains the directories fldr1, fldr2, and fldr3. Use your command to list a directory's contents with the path "fldr1\data\per", then use "fldr2\data\per", and so on until it doesn't return an error. Per may be empty, but that should look different from the path not found error.
Now you've found the name of your mystery folder. Write it down for future reference.
At thus point, you know the path to Test.txt, and the full path to the destination directory. Do a move command to relocate Test.txt, and you're done. I like to relist the contents of the target directory after to be comfortable that it arrived.
I have a website that runs off an OpenWRT router. I'd like to optimize the site by removing an files that aren't being used. Here is my directory structure...
/www/images
/www/js
/www/styles
/www/otherSubDirectories <--- not really named that
I'm mostly concerned about identifying images that are not used because those take the most space. But it would also be nice to identify style sheets and javascript files that are not being used. So, is there a way I can search /www and all sub directories and files and print a list of files in /www/images, /www/js, and /www/styles that are not referenced by any other files?
When I'm looking for files that contain a specific string I use this:
find . | xargs grep -Hn 'myImage.jpg'
That would tell me all files that reference the image. Maybe some variation of that?
Any help would be appreciated!
EV
Swiss File Knife is very nice tool.
Find out which files are used (referenced) by other files through fuzzy content analysis
Consider using a cross-reference program (for example, lxr) for this problem. (I haven't verified if lxr can do the job, but believe it can.) If an off-the-shelf cross-reference program doesn't work, look for an open source cross-reference program in a language you know, and adapt it.
In a solution with lots of files and projects - how would you find all completely commented files? I assume that every line of code starts with // (EDIT: or is empty) in such files.
I am using VS 2008, C#, ReSharper is available.
I know, normally such files should not exist - that's what a source safe is for ...
To find all files in and under the current directory in which all lines begin with '//':
find . -type f -exec sh -c 'grep -vq "^//" {} || echo {}' \;
Note that this will report empty files.
The argument to grep can easily be expanded to account for whitespace, or generalized to match an arbitrary regex.
There is no way to achieve this with a simple search style with the components you've mentioned. Doing this would require a bit of interpretation on the file but could be done with a fairly simple script.
It sounds like you're looking for files without code though vs. files with all comments. For example if there are 1000 lines where 900 are commented and 100 are blank, it seems to meet your criteria.
The script should be fairly straight forward to write but you would need to look out for the following weird cases
Block comments
if blocks which are always false. For example #if 0
Empty lines
Well, you could write a program (probably a console app) to recursively walk the directory and file tree. Read in all .cs files and check each line to see if its first non-space and non-tab characters are "//". If you wanted to get really fancy, you could count the total lines and the lines with "//" and display the percentages so you could catch files that didn't have absolutely every line commented out. You'll just need to understand a little bit about System.IO to get the files and string functions to look for the characters you are looking for. That should cover it.
This should be close to what you're looking for: http://www.codeproject.com/KB/cs/csharplinecounter.aspx
Look for the method in the project that determines if a line is commented or not, and you can use that to build a count, etc.