So I have the simple problem
In order to restore files, the original directory and filename must be
stored.
Create a hidden file called ".restore.info". Each line of
this file should contain the name of a stored file, followed by a
colon, followed by the original full path and filename.
For example,
if file f1 with inode 1234 were removed from the /home/usr1.name/
directory and another file named f1 with inode 5432 were removed from
the /home/usr1.name/testing directory then .restore.info would
contain:
f1_1234:/home/usr1.name/f1
f1_5432:/home/usr1.name/testing/f1
any ideas?
ls f* | parallel 'echo {}_`stat -c%i {}`:$PWD/{} >> .restore.info ;mv {} recycleBin/{}_`stat -c%i {}`'
hope this works +
Related
The System Under Test generates some pdf files and saves the files to a particular folder. The challenge is that the pdf file name is randomly generated and I don't know the name. I need to open the file from the folder which is the most recent one, but I can't seem to find a way to open the file.
I know part of the file name so I tried using wildcard for part of the file name, but it doesn't work
I removed all other files from the folder and kept only one file in the folder, and then used wildcard instead of the complete file name, but that doesn't work either
Is there a way that I can read names of files present in a folder? Or open a pdf file using wildcard character? Or open the first file in the folder?
You could try PowerShell scripting (please refer attached screenshots)
Use the 'TBox Start Program' module.
In the Path attribute, mention the complete path of your PowerShell exe file (Eg: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)
In the Directory attribute, mention the folder path(Eg: C:\Users\tosca\Documents\testfolder)
Put -command in arguments with ActionMode 'Select'.
As Argument, input the PowerShell script with your wild carded file name to copy the file name (Eg:
(Get-ChildItem filename | Sort-Object CreationTime -Descending | Select-Object -First 1).Name | Clip)
Copy latest file name
Then use 'TBox Clipboard' to store the dynamic file name using ActionMode 'Verify'
Save latest file name
Then you can buffer the target file as folderpath\filename.
Friends, I have a folder containing three files named as 1a.txt, 121a & 151a.txt. When I try to sort the files, file name 121a comes before 1a.
import os
path = r"C:\Users\Admin\Downloads\Telegram Desktop\number test"
files = os.listdir(path)
print(path)
Output:
C:\Users\Admin\Downloads\Telegram Desktop\number test
for file in files:
print(file)
But, what I want is 1a.txt, 121a.txt, 151a.txt. Need your useful feedbacks.
Thank you.
Rename to "001.txt": when format is overall the same, it will work.
I want to create a batch/shell script for windows and mac that will take few different files with different types and will compress it to a .zip file.
I already saw a few questions and answers about it, but all of them either compress all the files in the folder or compress them individually.
Example (look at attached image):
I have a folder that contains 1.txt, 2.xml, a sub directory.
And I want to turn all of them into a .zip file.
If possible to get a solution both for windows and Mac.
On Windows there is the file 7zip.chm in directory %ProgramFiles%\7-Zip which is the help file of 7-Zip. Double click on this file to open the help.
On Contents tab there is the list item Command Line Version with the help pages:
Syntax ... Command Line Syntax
Commands ... Command Line Commands
Switches ... Command Line Switches
The target is to compress everything in folder test into a ZIP file with name of the folder as file name.
This could be done for example with the command line:
"%ProgramFiles%\7-Zip\7z.exe" a -bd -mx=9 -r -y -- test.zip "C:\Path to Directory\test\*"
This command line adds (a) everything in directory C:\Path to Directory\test recursive (-r) to a ZIP file with name test.zip in current working directory without progress indicator (-bd) using best ZIP compression (-mx=9) with assuming Yes on all queries (-y).
In other words the file test.zip in current directory contains after execution the subdirectory main with everything inside and the files 1.txt and 2.xml.
Good evening,
I am currently working on a programm that takes information from a file into a Database, for testing purposes I used to open Testfiles in the classical way via IO:
function reader (file, delimeter)
local f = io.open(file)
for line in f:lines() do
lines[count] = splitty(line, delimeter)
count = count + 1;
end
end
(this part also containes the first part of a splitter)
But in the actual environment, the database programm imediatly moves the file in another directory with a name change to, for example this:
$30$15$2016$09$26$13$27$24$444Z$.Pal.INV.csv
Now I know the directory but I can't really predict the name, so I wanted to know if there might be a way to open files without knowing their name.
(and delete them after reading them)
I had ideas to use a modified link:
local inputFile = "D:\\Directory\\(*all)"
but it failed.
Other aviable information:
The system is until now only planned on Windows PCs.
The directory will always only contain the one file that is to ready, no other files.
You can use the lfs.dir iterator from LuaFileSystem to iterate through the contents of the directory. A small example:
local lfs = require("lfs")
local path = "D:\\Directory\\" -- Your directory path goes here.
for filename in lfs.dir(path) do
print(filename) -- Work with filename, i will just print it
end
If you keep a record of the files you will be able to know which one is the new one. If it is only one file, then it will be easier, you can just check the extension with a string function. From what i remember the iterator includes .. and .. lfs documentation can be found here.
-- directory name and file name should consist of ASCII-7-bit characters only
local dir = [[C:\Temp\New Folder]]
local file = io.popen('dir /b/s/a-d "'..dir..'" 2>nul:'):read"*a":match"%C+"
if not file then
error"No files in this directory"
end
-- print the file name of first file in the directory
print(file) --> C:\Temp\New Folder\New Text Document.txt
I want to copy a file to a user defined folder with different filename via batch file
Here folder path is supplied by argument
CODE
type abc > %1\\my_abc
but it does nothing than creating file in same folder
whats my mistake?
Why don't you use :
copy abc %1\my_abc