From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare 2 folder paths

I am currently using the recursive file list to browse through all the files and folders inside a specific folder. I want to compare the current folder the recursive file list is in to the next folder that will be browsed. I tried to use index array, but I just realized that this can't be done like this. can someone please tell me how can I compare the folder the recursive file list is currently in to the next folder in a recursive file list?

Thanks in advance

0 Kudos
Message 1 of 9
(4,589 Views)

Do you want to compare them to see if they are identical?

0 Kudos
Message 2 of 9
(4,579 Views)

You mean something like this?

 

Folder.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(4,569 Views)

As you can see by the responses, we need a definition of what you mean by "Compare folders".  I know that in a Utility I wrote, I wanted four lists of files -- Files that were the same (in content and location within the Folder Tree) in both Folders, files that were Unique to Folder 1, files that were Unique to Folder 2, and files that were in both Folders, at the same relative locations, but had different content.

 

You probably mean something different, but we can't guess what.  Also, are you talking about comparing Folders at just the top level, or as a tree, including its sub-folders?

 

Bob Schor

0 Kudos
Message 4 of 9
(4,558 Views)

ething like that, but the thing is that the folder name is the same. What I want is to strip the path and obtain just one folder name.

I made something that extracts the folder name I am looking for, but now I tried to make it work for the next folders and it gives me an empty string.

Folder comparison is the one that doesn't work.

Download All
0 Kudos
Message 5 of 9
(4,541 Views)

Ah, I see the problem -- you were the one who asked about how to "Get the first Folder Name of Path", noone understood what you wanted, you posted Extract Folder as the "Solution" (but I argued that it wasn't a "solution" to the question that you asked), and now you want "something else", but it still isn't clear (to me, anyway) exactly what you want or need.

 

Can you give us an example?  You may need to show a directory tree, indicate where you start in the tree, and what you are trying to accomplish.  [I still have no idea what Extract Folder really does ...].

 

Bob Schor

0 Kudos
Message 6 of 9
(4,526 Views)

let's say you have "D:\Works\Fernando\CRS\ASA - CRS\Archives\Flash\Galeria Fotos\Galeria\test\thumbs\main", and the main folder will be changing, because there are a lot of folders inside the thumbs folder. I want to compare if the first main folder is different from the second main folder, because what I am trying to do is write an xml as text and I need the path to the file, but not the complete path, and I need to do this for every folder inside the thumbs folder, because for every new folder, there has to be this written in the text file <dir></dir>, and inside thids will be all the info that is required by the xml.

0 Kudos
Message 7 of 9
(4,517 Views)

I may have found a solution, but I am still having trouble implementing it. I thought that it would be better to right all the lines to a text file and then read those lines into an array and then use index array to compare with the use of shift registers, but I still get false.

I will leave an example of what I am trying to do.

0 Kudos
Message 8 of 9
(4,483 Views)

@Nando88 wrote:

let's say you have "D:\Works\Fernando\CRS\ASA - CRS\Archives\Flash\Galeria Fotos\Galeria\test\thumbs\main", and the main folder will be changing, because there are a lot of folders inside the thumbs folder. I want to compare if the first main folder is different from the second main folder, because what I am trying to do is write an xml as text and I need the path to the file, but not the complete path, and I need to do this for every folder inside the thumbs folder, because for every new folder, there has to be this written in the text file <dir></dir>, and inside thids will be all the info that is required by the xml.


OK, now I see why you have "thumbs" in part of your code.  I'm going to abbreviate your path, above, to the following to save space:  "D:\F1\F2\F3\F4\F5\F6\F7\F8\test\thumbs\main.  So here are some things that are still unclear to me:

  • What is the common path for all of the files you are considering?  Is it D:\F1\F2\F3\F4\F5\F6\F7\F8\test, D:\F1\F2\F3\F4\F5\F6\F7\F8\test\thumbs, or something else?
  • You speak about the "first main folder" and "second main folder".  One "main folder" is located in \test\thumbs -- where is the other folder located?
  • What are you given as a starting Path?  Is it a File or a Folder?  If a folder, is it D:\F1\F2\F3\F4\F5\F6\F7\F8\test\thumbs\main, or a "shorter version" of this path?  Is the starting path always "absolute", meaning that the Drive Letter is included?

Given that you know where you want to start, and know "how far up the tree" you want to start your search, and what it is you want to find, there are perfectly reasonable (and easy-to-use) LabVIEW File/Folder tools that should be easily able to accomplish your task.  The tricky part is to define the task clearly (which, as least for me, you have not yet done).

 

Bob Schor

0 Kudos
Message 9 of 9
(4,452 Views)