Command Prompt / List files within specified sub folders - directory

I have a Directory with 100 sub folders. Call them Top 1, Top 2, Top 3. Within each of those I have 3 dozen sub folders. Call them Sub 1, Sub 2, Sub 3, etc.
I need to find all files within Sub 2, for each Top folder. The top folder name varies. But each Top folder has the same exact Sub folder structure.
All of the files within the Sub 2 can be listed regardless of their file extension.
\Top 1\Sub 2
\Top 2\Sub 2
\Top 3\Sub 2
etc.
Is there a Command Prompt that can help list this?
Cheers,

If os is windows
tree command if I remember it right.
Will do

Related

Apple Script: when moving a file into a folder, is it possible to move duplicates inside that folder?

I have an apple script which moves all files within a folder into a new folder according to the first 6 characters of the filenames.
If the folder already exists, the files get moved into that existing folder instead.
If the file already exists in the new/existing folder, the file to be moved into the folder gets a "copy" extension to the filename – which is not in the script, it's a system function ;-)
My question:
Is it possible to move all existing (duplicate) files into a subfolder (named "_alt" for example), before the other files get moved within the folder (to prevent the "copy"-extension)? I would like to keep both files, the original files and the newly moved files.
Thanks.
This is my existing script:
set mgFilesFolder to (choose folder with prompt "Choose folder…")
(* get the files of the mgFilesFolder folder *)
tell application "Finder" to set fileList to files of mgFilesFolder
(* iterate over every file *)
repeat with i from 1 to number of items in fileList
set this_item to item i of fileList
set this_file_Name to name of this_item as string
set thisFileCode to characters 1 thru 6 of this_file_Name as text
log thisFileCode
tell application "Finder"
try
set nf to make new folder at mgFilesFolder with properties {name:thisFileCode}
end try
end tell
end repeat
set sourceFolder to mgFilesFolder
set destinationFolder to mgFilesFolder
tell application "Finder"
set the_files to (get files of mgFilesFolder)
repeat with this_file in the_files
set the_name to name of this_file
set the_short_name to items 1 thru 6 of the_name as string
if exists folder the_short_name of mgFilesFolder then move this_file to folder the_short_name of mgFilesFolder
end repeat
end tell

Moving files between folders when folder names match partially (in R or VBA)

I'm trying to solve the following problem
I have 9 folders titled PROS_2010 to PROS_2019. Each of them has about 500 subfolders with names structured as follows e.g. PROS_201001211_FIRM NAME_number. Each subfolder has a variety of pdf files with different names.
I have created in VBA another folder called sample with about 400 subfolders, each of which is named a specific FIRM NAME. For this I used the following code:
Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
I now want to move all the pdf files that are in the original subfolders PROS_201001211_FIRM NAME_number to the folders titled FIRM NAME only.
Basically, each original subfolder contains a report about a firm for a specific year (2010 to 2019) and I want to get all the firm reports for all years in a single folder titled FIRM NAME
To make it easier I already have an excel file that basically has the complete list of subfolders that looks like this:
Data structure: Company name is the name of the folder in which I want to move the files that are currently in "attachment folder". attachment1 is the pdf file name (which always changes so ideally the code would pluck all the files in attachment folder and move them to the file with company name
Thanks in advance,
Simon
OK
So thanks to the help of a mate I found it is super easy to solve this problem using the "command" command in windows
Basically create a text file (in notepad) that has the following structure
move "original pdf file directory" "new pdf file location\"
...
Repeat the structure for each file (which requires some basic excel string manipulations)
Then save the .txt file as a .cmd file and open it.
Done

Finding Test set and Sub folder from a parent folder in QC Test Lab

I am trying to extract sub folders (not all children folders) along with Test sets(not all children test sets, only next test set) from a parent folder in QC test Lab.
Let suppose There are 2 sub folders and 1 test set in a Parent folder in QC:
-Parent Folder1
- Sub folder1
- Sub folder2
- Test Set
Using the below code i am able to extract the subfolders only not test sets:
Code:
Set TsetMgr = UserForm9.QCConnection.TestSetTreeManager 'object required
Set Root1p = TsetMgr.Root 'connect to Root
Set SubNodesRoot = Root1p.SubNodes() 'Using SubNodes method to extract SubNodes from QC
For rp = 1 To SubNodesRoot.Count 'Total SubNodes available
c1p = SubNodesRoot.Item(rp)' Finding SubNodes
MsgBox(c1p) ' SubFolder1 and Subfolder2 values are displayed.
Next
My only problem now is, i am not able to extract Test Sets along with subfolders from a parent folder.
Can anyone please help me fix this. Thanks.
I don't think there is a way to get both folders and test sets with calling one function. But you can get the folders with the method you described. And you can get the immediate child-test-sets of a TestSetFolder via the TestSetFactory of this folder:
test_set_factory = lab_folder.TestSetFactory
test_sets = test_set_factory.NewList("")
test_sets.each do |test_set|
puts "Test Set: #{test_set.Name}"
end
That should print you the names of all TestSets in the lab_folder. I think you cannot have TestSets directly in your root folder, so you can use the TestSetFactory only on sub folders.

Classic ASP virtual includes

Lets suppose I have the following file structure, the top 4 of which are virtual dirs:
1/2/3/4/5/6/7/8
Is it possible, from a file in directory 8, to include a file in directory 4, using something like the following?
<!-- #include virtual="/4/5/6/a.asp" -->
Note that I don't have 8 levels of directories - I actually only have 3 in the format /ab/abCore/includes.asp, /ab/ab123/default.asp, /ab/ab123/ajax/ab.asp, /ab/ab123/actions/create.asp (may have more levels shortly) and would like to use the same includes in both default.asp and create.asp. The only way I can find is to use 'file' with '../' one or more times. ab is a virtual directory but abCore and ab123 are not. I need to reference virtual dir 'ab' from any files within any directories within this directory. I am just using 8 in my example merely to explain my situation better. Note that I have full control over IIS, defining which directories are virtual and so on.
If this is not very clear then please say (rather than downvoting) and I will try to rephrase.
Yes it can be done. Suppose there is a file test1.asp in f1 folder and you want to include it in a file which is in the path f1/f2/f3. Simply you need to write the code like
<!--#include file = "..\..\test1.asp"-->
So here is your answer. Your code should be like
<!--#include file = "..\..\..\..\a.asp"-->

Listing directory from database in order and showing sub folders and files. Classic ASP

I know there are solutions out there for showing a windows directory of folders and files but mine is from a virtual directory within a database.
I have it so far that when you click a show me button it shows the directory path you are in e.g.
folder 1.1.1
folder 1.1
folder 1
it displays in this order but i want it to display the main directory at the top.
I would also like to be able to make the list of files clickable so that you can go straight to a specific file or folder when you click the show me button to make it easier for users to find the file they want. Is it possible to display sub-directories without been inside them?
My code for displaying the directory path you are in is:
dim previousPos
previousPos = 0
dim html
html = ""
if not test.BOF then
do while not objRsU.EOF
'if previousPos = (test.Fields(2)) then
response.Write html & "<br />"
html = ""
'else
html = test.Fields(0) & "\" & html
'end if
previousPos = test.Fields(2)
test.MoveNext
loop
end if
set test =nothing
set try =nothing
ListFolderContents Server.MapPath("/"), 0
sub ListFolderContents(path, level)
dim fs, folder, file, item, subFolders
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
if folder.SubFolders.Count > 0 or folder.Files.Count > 0 then
'Display the target folder and info.
if level > 3 then
Response.Write("<h2>"& folder.Name &"</h2>" & html)
end if
'Display a list of sub folders.
for each item in folder.SubFolders
ListFolderContents item.Path, level + 1
next
'Display a list of files.
Response.Write("<a<ul></a>" & html)
for each item in folder.Files
Response.Write("<li>" & try.Name & "</li>")
next
Response.Write("</ul>" & html)
end if
end sub
This second part of the code displays the Main folder of the directory.
Any help would be very much appreciated.
Thanks
Why don't you just use something like this instead? It supports Classic ASP.
http://ckfinder.com/

Resources