Tag Info

New answers tagged

2

By using Leonid's makeTree from here: makeTree[wrds_] := Reap[If[# =!= {}, Sow[Rest[#], First@#]] & /@ wrds, _, #1 -> makeTree[#2] &][[2]] usage fn = {"Folder1\\file1.txt", "Folder2\\file3.dat", "Folder3\\file4.nb", "Folder3\\file5.m", "Folder3\\file6.m", ...


2

The following use DepthFirstScan (graph programming) and is cleaner IMHO: f[ac_, son_, papa_, n_] := If[n != 0, ac /. Longest[{papa, s_List} | papa] :> {papa, Append[{} ⋃ s, son]}, Append[ac, papa]] format1[fn_] := Module[{g, heads, ac = {}}, g = Graph@Union@Flatten@Apply[Rule, Partition[#, 2, 1] & /@ FileNameSplit /@ fn, ...


1

A recursive approach that groups as required and will work for any folder depth and reoccurring folder names at different locations in the directory hierarchy. fileNameList = {"Folder1\\file1.txt", "Folder2\\file3.dat", "Folder3\\file4.nb", "Folder3\\file5.m", "Folder3\\file6.m", "Folder3\\Folder31\\file11.log", "Folder3\\Folder31\\file12.log", ...


2

Using the Graph representation: A caveat at the end. format[fn_] := Module[{g, heads, rul, res}, g = Graph@ Union@Flatten@Apply[Rule, Partition[#, 2, 1] & /@ FileNameSplit /@ fn, {2}]; heads = Select[VertexList@g, Length@VertexInComponent[g, #] == 1 &]; rul = ({# -> {"$" <> #, Rest@VertexOutComponent[g, #, 1]}} & /@ VertexList@g); ...


3

I think this is it. I hope that will be useful. And I would be grateful for any improvements. First some auxiliary functions. DeleteBracketsOnAtoms[lst_] := If[Length[#] == 1, First[#], #] & /@ lst MyDirList[dir_] := Quiet@Module[{rawres, splitted},SetDirectory[dir]; rawres = Select[FileNames["*", "", Infinity], DirectoryQ[#] == False &]; ...


8

See FileDate FileDate["file","type"] gives information on the specified type of date associated with a file. Global System Information will unveil more details.


1

To use Put or PutAppend with a filename saved in a string in terminal, one can use it in input form rather then >> or >>>, that is: filename="newfile.txt" Put[expression,filename] or PutAppend[expression,filename] I found the answer in http://stackoverflow.com/questions/8853676 by Brett Champion. While this solves my problem, I would ...


1

I would suggest the workaround to create smaller files and use the sum of FileByteCount[] of each file as a check while exporting.



Top 50 recent answers are included