I am trying to loop through all the files in a folder and get the path of one that contains a specific part of text. The text is not always in the same position and the folder is a network folder.
What would be the fastest way to do this in a network folder that contains hundreds of files with more than 30Mb each?
The Dir() solution did not work as it says "Bad file name or number" (Error 52). I am referencing the network path as \\thisisthefolder\anotherfolder\
Related
Sorry if my wording is a little weird, but I don't know how to summarise what's wrong.
I'm using a macro in LibreOffice Calc which takes the selected cell and opens a folder in explorer. I want the spreadsheet to also find what folder it is in so that it can be moved anywhere and still work. So far, I have got it to open a folder based on the cell that is selected, and I can get it to figure out what folder it is in.
I am trying to tack on and additional part of the folder path that will be dependent on the selected cell, and then have the program open that folder.
Here is my code:
If oConv.UserInterfaceRepresentation = "Sheet4.A1" then
OpenFolder = ThisFolder & "/NewFolder"
shell ("C:/Windows/explorer.exe",1,OpenFolder)
End If
'ThisFolder' is the folder that the spreadsheet is currently in, and 'OpenFolder' is the new folder path that is supposed to be opened depending on the selected cell. The problem is that LibreOffice just ignores the '& "NewFolder"' and opens the path defined for 'ThisFolder'. What's even weirder is that If I watch the variable 'OpenFolder' and go step by step, it shows the full path for that variable including the 'NewFolder' before it does the shell command.
How can I get it to open the 'NewFolder'?
I need to save dataset values into a local folder path.
The dataset value I'm getting is another folder path. This has to be achieved in console application.
Suppose dataset value has c:\priyanka path after running the console application. The data has to be populated but to a new path like c:\Desktop. The data from one folder path has to be copied to another folder.
How we can I achieve this?
I have new text files every month from where I extract the data and do some transformations. In the end of every month, I need to move these files to a folder with current date in name. Which means, the destination folder's name is different everytime.
I made a step before move files that creates a folder and its name is current date (exp: 2019-06-01, 2019-07-01), but then on move files step, I don't know how to specify the destination folder. Guess "wildcard" is only used for source...
Otherwise, on move files - Destination file - Move to folder, there is create folder option, thought it could be a solution but as on the screenshot, this section can't be modified. What is the reason?
Does anyone have an idea ?
Thanks for reading :))
You can utilize this approach for this task.
Basically you'll have to extract the date you want from each file before doing the transformations, and after all the transformations are done, you'll use the JOB step 'Move files', but instead of passing a fixed destination, you'll use variables in the path, much like this answer, but you don't need to create the folder before, you can just use the option on the 'Move files' step, so the folders are created at run time.
I have attached an example of this approach with some commentary in the KTR/KJB.
You can download here
Let me know if the link is working, this is my first time posting an external file in StackOverflow
e.g. have a line be saing "save ('hp=30,x=3,y=74,mode=7')=save.txt"
and after executing it there will be a text file named "save" in the folder with the executable, and will contain "hp=30,x=3,y=74,mode=7", is that possible? And is it possible to "load" it so it will give specified silible its content?
I'm trying to build a program that gets users name at first. This user names are kept in a text file. After user logins, according to the user's name, I want user to be lead his/her specific informations. I figured out that I can only do it with a file that is created when he sign up for an account which I direct him with my sign up button in Livecode. While he/she create his account I want to create a specific file for his/her. Can you help me with it please?
PS: I don't want to do it with a database right now. I just want to learn how to create a file without a specific name like
put specialFolderPath("documents")&"/userLoginCridentials.txt" into tFile put URL("file:"&tFile) into myFile
Instead of this "userCridentials.txt" I want something user can create with his own name :)
Having a little problem to understand your question. Are you targeting mobile or desktop? Are you having problem saving or reading the data?
If saving is you problem
On desktop you can use:
ask file "Save file as:"
then you get the filename back in it so you can use:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put tData into url ("file:" & tFile)
end if
If you targeting mobile and would like to save into the specialFolderPath("Documents")you can get the filename from a field and then save to that file. E.g. if you have a field named 'fileName' you can use something like:
put tData into url("file:" & specialFolderPath("Documents") & "/" & field "fileName"
Of course you should do some error checking to ensure that a user don't overwrite existing files without at least asking for permission, etc.
You can of course use a variable instead of a field...
If reading data is your problem
On desktop you can use:
answer file "Open File:"
Same as above but you now read data instead:
if it is not empty then
# We have a complete file path in 'it'
put it into tFile
put url ("file:" & tFile) into tData
end if
on mobile you probably would like to present a list with the user-created files. In LiveCode you can list all files in the defaultFolder with the files. But you must set the defaultFolder to the folder you want to list.
set the defaultFolder to specialFolderPath("Documents")
put the files into tFiles
Now tFiles contains every file in that folder and you can filter it, display it in a list etc. E.g:
filter tFiles with "*.txt"
put tFiles into
If your problem is how to remember the "current" file name
Whenever you restart your app every variable is reset. So everything you want to remember between runs needs to be saved before your app quits. And for that you need a predefined filename. SO then your procedure will be:
Read in the predefined file.
Grab the file name from within that file
Read the file
If your problem is something else
Sorry, then I misunderstood your question...