I have a list of filenames in a text file like this:
f1.txt
f2
f3.jpg
How do I delete everything else from a folder except these files in Powershell?
Pseudo-code:
Read the text file line-by-line
Create a list of filenames
Recurse folder and its subfolders
If filename is not in list, delete it.
Thanks in advance.
~HP
...
This works quite nicely - just wondered if there are any improvements to shorten it ?
if (ARGV[0].nil?) then
input=$<
else
input=File.new(ARGV[0],"r");
end
...
# Do something with the input here, for example:
input.each_line do |line|
puts line
end
...
I have a script that regularly creates a new folder on the network and saves files to a folder. When this script is run, it creates a shortcut to the folder just created.
What I really want is for all my users to be able to have a shortcut on each of their desktops that points to the most recent folder.
I'd thought I'd be able to prov...
My company downloads numerous files on a daily basis via ftp. Currently these files are stored in a fairly large file hierarchy, which is cumbersome to navigate. In addition the files often have meaningless names making them difficult to identify.
We are considering building an application that presents a rich "filesystem" to the user...
Disregarding my last post, I've found the source of the problem. I'm using
a.renameTo(b)
when b doesn't exist. The reason it doesn't exist is because there is a symbolic link so if b is "/usr/name/folder/file", then b really is "/mnt/MountTest" because the symlink is to that directory.
So the question is, is there an alternative way...
I've got a large (by number of lines) plain text file that I'd like to split into smaller files, also by number of lines. So if my file has around 2M lines, I'd like to split it up into 10 files that contain 200k lines, or 100 files that contain 20k lines (plus one file with the remainder; being evenly divisible doesn't matter).
I coul...
how do I extract 12byte chunks from a binary file at certain positions within the file.
If I wanted to extract the first 12 bytes I could do something like
head -c12 file.bin>output
If I wanted to extract 12 bytes from byte61 I could do something like
head -c72 file.bin|tail -c12 >output
Is there a simpler way if I have something ...
Is it possible to add ZIP file to APK package as a raw resource and read it with ZipFile class? It looks like it's trivial to open file from SD card, but not from APK.
...
I am trying to create a file in Apache for writing debugging messages (Just to write some log messages).. But unable to create a file under Apache module.
Just check out my code & kindly help me out!
Do advice me with a code snippet, is there any way to log debugging messages under Apache??
============
(Header files are removed for ...
Can I load multiple language files for the same view in CodeIgniter?
...
Hello ,
I have a Font object in Java for a font file ... I need to convert that object to a File object or get the font file path ... So i can pass it to another method.
Is there a way to do this ?
Thanks ...
---------------------------------------------------------- Edit: More explanation :
What i'm doing here is calling a method...
Hi,
I want to delete cache files in a directory, the directory can contain up to 50.000 files. I currently I use this function.
// Deletes all files in $type directory that start with $start
function clearCache($type,$start)
{
$open = opendir($GLOBALS['DOC_ROOT']."/cache/".$type."/");
while( ($file = readdi...
Ok, so here's the problem: I'm reading the stream from a FileUpload control, reading in chunks of n bytes and writing the array in a loop until I reach the stream's end.
Now the reason I do this is because I need to check several things while the upload is still going on (rather than doing a Save(); which does the whole thing in one go)...
I'm getting an error in a program that is supposed to run for a long time that too many files are open. Is there any way I can keep track of which files are open so I can print that list out occasionally and see where the problem is?
...
Hello Everyone! How can i do this?
I know ho to do this on windows, but here.. im newer ))
SDK: Mac OS X 10.5
...
I use the Python Image Library (PIL) to resize an image and create a thumbnail.
Why is it that my code produces an image that is so crappy and low-quality? Can someone tell me how to modify the code so that it's the highest quality JPEG?
def create_thumbnail(buffer, width=100, height=100):
im = Image.open(StringIO(buffer))
if im...
Hi everyone ,
Is there is command in jython which can compare line by line between two files and display the non-matching record.
Thanks
...
I'd like to create a very simple android activity that takes a file path on the sd card and displays the contents of that directory in a listview.
I know how to get a list of the files via File.listFiles() which returns an Array of File objects. What I want to know is how I can adapt that array to a ListView. Would an ArrayAdapter be ...
Hi all
I've added a resource file to my project called CrpResource.resx .
Then, after adding a text file to the resource file, I wanna to access to it and read from it by code.
any suggestion please.
...
Hi all, i looking for your help please
i use simple php code like:
$file = $_SERVER["SCRIPT_NAME"];
//echo $file;
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
echo $pfile;
than output $pfile e.g. fileforme.php
but that i want is output of $pfile become fileforme
because i want use it to:
$txt['fl']= $pfile ;
...