w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Bash script that move files from one directory with lots of files to a month folder
something like this? DEBUG=echo cd ${directory_with_files} for file in * ; do dest=$(stat -c %y "$file" | head -c 7) mkdir -p $dest ${DEBUG} mv -v "$file" $dest/$(echo "$file" | sed -e 's/.* (.*)/1/') done DISCLAIMER: test this in a safe copy of your files. I won't be responsible for any lost of data ;-)

Categories : Bash

Umbraco & TFS - Including hidden files
I came across this article which explains how to 'blanket' include files or folders in a .csproj file. In a nutshell you can add the following references: <Content Include="PathToFolder**" /> <Content Include="PathToFolder*.*" /> <Content Include="PathToFolder*.jpg" > So in the case of Umbraco you will first need to exclude the following folders from the project: /umbraco /umbraco_client /media /masterpages /views /macroscripts /xslt then open up the .csproj file in a test editor and add: <Content Include="umbraco**" /> <Content Include="umbraco_client**" /> <Content Include="media**" /> <Content Include="masterpages**" /> <Content Include="views**" /> <Content Include="macroscripts**" /> <Content Include="xslt**" /> S

Categories : Visual Studio 2012

Counting Files with Bash
What about: list_and_count_files() { local content local count count=0 for content in "${1:-.}"/*; do printf "%s " "${content##*/}" ((count++)) done printf " Total: %d " "$count" } This name is a more accurate description of what your original function does. Note that the directory to be analyzed is passed as an argument to the function, but defaults to . (the current directory) if you don't pass anything. This decouples the function from the variable $dir_name, which is much better for isolation.

Categories : Linux

BASH | Adding elements in all files of a specific directory bash
This can make it: for file in /your/dir/* do echo "<end>" >> "$file" done In case you have some dirs inside, you may get the error bash: XX: Is a directory. To avoid seeing them, you can add 2>/dev/null to the end of the echo command: echo "<end>" >> "$file" 2>/dev/null Or even better (thanks Barmar), check if they are files: [ -f "$file" ] && echo "<end>" >> "$file" Which is a short way of doing an if-condition: if [ -f "$file" ]; then echo "<end>" >> "$file" fi

Categories : Bash

Bash Script to Find a Symbol in a Substantial Amount of .jar Files
The jar usage seems ok, but there are too many variables, arrays, pipes that could have been avoided. The following should work for you: for i in `find ${PWD} -name "*.jar"`; do jar -tf $i | grep -qs $1 && echo $i done This would list the jar file(s) containing the symbol.

Categories : Bash

Bash Tab Completion Suggests Hidden SVN Files
The tab completion does not exclude hidden files. It is acting as intended. If you do a ls -a it will show the hidden files. It is worth noting that any files/folders that start with a . are hidden files. Command line assumes that you will need access to these files which is why it is suggesting them in the auto complete.

Categories : Bash

Maven: including non-java files from more specific directory
Change it to, may be there is no more sub dir to look into <resources> <resource> <directory>src/main/java/com/oppballi/kanake</directory> <includes> <include>*.txt</include> </includes> </resource> </resources>

Categories : Java

How to print all files in a directory including subdirectories without recursion in j2me
Make the stack explicit. I've done this in pseudo-code as this sounds a little home-worky! Your current structure is a little like this: public void List(Directory directory) { forevery file in directory if (isDirectory(file)) List(file) else print(file) // recursion uses a stack } Instead you can make the call-stack explicit using your own stack. The recursion becomes replaced with a while loop. public void List(Directory directory) { Stack directories = new Stack(); directories.push(directory); while(!directories.Empty()) { Directory dir = directories.pop(); forevery file in dir if (IsDirectory(file)) directories.push(file) else print(file); } }

Categories : Java

For Android project how do I get maven to pickup all libraries in lib directory including .so files?
These jars should be included as dependencies in the maven POM. Rather than include them in a local lib folder they should be deployed to a maven repository. For any artifacts that are available through maven central repository just include the dependency directly from there. For custom artifacts, the best way to do this is to set up your own maven repository (http://archiva.apache.org/index.cgi or http://www.sonatype.org/nexus/) and deploy the artifacts to that. Then you can include them as dependencies in the pom. Alternatively, if this is overkill for your project, you can set up a local project repository and deploy the artifacts to that. I havent actually done this with JNI libraries, though this link looks like it may contain useful info for doing a similar thing there: http://

Categories : Android

UNIX: How to change all hidden folders/files to visible in a directory
I am not sure why you would want to do this but you could do the following three commands ls | grep "^." | sed -e "s/.(.*)$/mv 1/" > mv_hidden . mv_hidden rm mv_hidden You might want to check that the list of command produce in the file mv_hidden looks correct.

Categories : Unix

Bash - Printing Directory Files
Here is a solution: #!/bin/bash target="/home/personal/scripts/07_22_13/ford/$1" let count=0 for f in "$target"/* do echo $(basename $f) let count=count+1 done echo "" echo "Count: $count" Solution 2 If you don't want to deal with parsing the path to get just the file names, another solution is to cd into the directory in question, do your business, and cd back to where you were: #!/bin/bash target="/home/personal/scripts/07_22_13/ford/$1" pushd "$target" > /dev/null let count=0 for f in * do echo $f let count=count+1 done popd echo "" echo "Count: $count" The pushd and popd commands will switch to a directory, then return.

Categories : Linux

BASH if directory contains files or doesn't
find could be helpful here: if [[ $(find ${dir} -type f | wc -l) -gt 0 ]]; then echo "ok"; fi UPD: what is -gt? man bash -> / -gt/: arg1 OP arg2 OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to arg2, respectively. Arg1 and arg2 may be positive or negative integers. So, -gt is "greater than" boolean function.

Categories : Bash

monitor a directory and pull new files as they appear - bash script
Two products come to mind depending on how you plan to approach the solution. I personally use Splunk on a variety of platforms (Windows & Linux servers/local Linux & OSX dev environments). It is a real-time log aggregator that features an API and the ability to query. Even if this doesn't solve your problem, the free version has some very robust features that you should consider: http://www.splunk.com The second approach would be synchronization of your web directories using something like RSync. I've used RSync on Linux boxes and always appreciated what it can do. I even see it now has a Windows port: https://www.itefix.no/i2/cwrsync

Categories : Bash

Bash - replace string inside all files in directory
I would do this using sed like so: sed -i "/^[ ]*ODI_SESJA_ID CONSTANT/s/'[^']+'/'REPLACEMENT'/" *.ctl The -i flag to sed means it modifies the files in place, so I usually try it on a single file first with the -e flag instead of the -i flag and confirm that sed's output is what I was looking for. Explanation: The double-quotes protect my regex from the shell. /^[ ]*ODI_SESJA_ID CONSTANT/ matches only the lines that start with whitespace followed by 'ODI_SESJA_ID CONSTANT'. s/'[^']+'/'REPLACEMENT'/ substitutes 'REPLACEMENT' (quoted) for the first quoted portion of the text on matching lines. The document at http://www.catonmat.net/blog/wp-content/uploads/2008/09/sed1line.txt (top Google hit for 'sed one liners' is pretty helpful for quickly dispatching these sort of tasks.

Categories : Bash

bash: find all files in a directory and use part of the name as argument for a command
Try: find . -name "*.jpg" -exec sh -c 'mycommand -in $0 -out "${0%.*}.tif" --otherparam paramvalue' {} ; This will pass command of the form mycommand -in <imagebasename>.jpg -out <imagebasename>.tif --otherparam paramvalue to -exec. EDIT: For removing leading ./, you could say: find . -name "*.jpg" -exec bash -c 'f={}; f=${f/.//}; echo mycommand -in "${f}" -out "${f%.*}.tif" --otherparam paramvalue' {} ; (Note that the interpreter for -exec has changed.)

Categories : Bash

Serving static files( including HTML files). Nginx vs Node.js. Which one is more scalable?
Both Node.js and Nginx are asynchronous (non-blocking) servers. Nginx is definitely more well suited for serving your static files. However, depending on your use case, the difference may not be worth the added administration overhead. You would really have to be running a significant amount of traffic before you would notice the difference.

Categories : HTML

Using batch files to copy all files from a directory tree to a single directory
@echo off set "COPY_FROM=C:UsersmeDesktopDisc 1" set "COPY_TO=C:Testing est" md "%copy_to%" 2>nul cd /d "%COPY_FROM%" for /f "delims=" %%a in ('dir /b /s /a-d') do copy "%%a" "%COPY_TO%" pause

Categories : Batch File

When building deb files using dpkg, I can't get it to ignore hidden files such as .git and .gitignore
I ended up placing my package root in a subdirectory and creating a build script at the root that created all the empty directories I needed, so I wouldn't need .gitignore files and the .git file would no longer get packaged.

Categories : Ubuntu

Gallery Is Missing Files From Directory- How To Retrieve All Files From Directory
An alternative approach you may want to use to secure your list of thumbnails: $directory = 'thumb'; //where the gallery thumbnail images are located $files = glob($directory."/*.{jpg,jpeg,gif,png}", GLOB_BRACE); natsort($files); //sort by filename Then to render it out simply do this: <?php for($x = 0; $x < count($files); $x++): $thumb = $files[$x]; $file = basename($thumb); $nomargin = $x%4 == 0?" nomargin":""; $title = htmlspecialchars($file); ?> <div class="thumbs fancybox<?= $nomargin ?>" style="background:url('<?= $thumb ?>') no-repeat 50% 50%;"> <a rel="group" href="images/'.<?= $file ?>" title="<?= $title ?>"><?= $title ?></a> </div> <?php endfor;

Categories : PHP

How to create a bash script that will lower case all files in the current folder, then search/replace in all files?
Something like this should work: #!/bin/bash for file in *.html do lowercase=`echo $file | tr '[A-Z]' '[a-z]'` mv "$file" "$lowercase" for f in *.html do sed -i "s/$file/$lowercase/g" "$f" done done Change *.html to *.<extension> if you're working with something other than html files.

Categories : Bash

Select multiple files (different files from different directory) with 1 input type file element.
Using more than one <input type="file" /> element for your form is the best you can do. It's not possible to select multiple files from different directories in a single upload dialog.

Categories : HTML

quickest way to count the number of files in a directory containing hundreds of thousands of files
What you do right now reads the whole directory (more or less) into memory only to discard that content for its count. Avoid that by streaming the directory instead: my $count; opendir(my $dh, $curDir) or die "opendir($curdir): $!"; while (my $de = readdir($dh)) { next if $de =~ /^./ or $de =~ /config_file/; $count++; } closedir($dh); Importantly, don't use glob() in any of its forms. glob() will expensively stat() every entry, which is not overhead you want. Now, you might have much more sophisticated and lighter weight ways of doing this depending on OS capabilities or filesystem capabilities (Linux, by way of comparison, offers inotify), but streaming the dir as above is about as good as you'll portably get.

Categories : Perl

Including source files in C files
When you are including that source file you are getting 2 main() declaration which is incorrect. So you have redefined "main" in this case. Including .c into another .c file doesn't make sense. C files compile to .obj files, which are linked by the linker into the executable code , so there is no need to include one .C file into another. Instead, you can make a .h file that lists the functions and include that .h file

Categories : C

Recursively adding .org files in a top-level directory for org-agenda-files takes a long time
I also tried "recursive directory listing" at Emacs startup. It simply is way to loooong to be usable. So, try to stick with a limited number of "root" directories where you put your agenda files. Even better is sticking with "~/org", and possibly a few subdirs like "work" and "personal", and that's it. You can put there your agenda files, and have links Inside them to your real project root dirs. I know, this is not optimal, but I don't have anything better right now.

Categories : Emacs

deleting all zip files in target directory and only keeping latest two zip files
Not a optimized one but you can use. String[] extensions = {"zip","rar"}; Collection<File> fileList = listFiles(FilePath2,extensions,false); File[] fileArray = new File[fileList.size()]; int x = 0; for (Iterator iterator = fileList.iterator(); iterator.hasNext();) { fileArray[x] = (File) iterator.next(); x++; } File temp; for(int i=1; i< fileArray.length ; i++) { for(int j=0; j<fileArray.length-1; j++) { if(fileArray[j].lastModified() > fileArray[j+1].lastModified()) { temp = fileArray [j]; fileArray [j] = fileArray [j+1]; fileArray [j+1] = temp; } } } for(int i=0; i< fileArray.length-2 ; i++) { deleteQuietly(file

Categories : Java

keeping last 7 days zip files and deleting rest all files from a directory
Do you really need to sort and all? If you need to delete files which are more than 7 days old, get the lastModifieddate and substract it from current time. if the difference is more than 7*24*60*60 seconds then you can delete it. All you need is a for loop after the f.listFiles() line. Not actual code - use to get to the working code. long timeInEpoch = System.currentTimeMillis(); // slightly faster than new Date().getTimeInMillis(); File f = new File("/tmp"); if (f.isDirectory()) { final File[] files = f.listFiles(); for(int i =0; i < files.length ; i++ ) { if( timeInEpoch - f.lastModifiedDate() > 1000*60*60*24*7 ) files[i].delete(); } System.out.println(fileList); }

Categories : Java

According to files names of a file, duplicate files into anther directory
You need to turn the first file into a set (for fast membership testing). You are also using os.walk, which gives you three pieces of information, the path to the directory, a list of subdirectories and a list of the files in that directory: import sys import shutil,errno import os srcDir = 'Root' dstDir = 'De' with open('file.txt','r') as f: read_filenames = {fname.strip() for fname in f} # set comprehension for root, directories, files in os.walk(srcDir): for filename in read_filenames.intersection(files): shutil.move(os.path.join(root, filename), dstDir) The .intersection() call returns all elements in the read_filenames set that are also in the files list. Note that I tell shutil.move() the full path of the file to move to dstDir, using os.path.join() based on th

Categories : Python

Maven - unpack files from jar if jar is used, copy then extracted files to a directory
The m2e-plugin can neither execute the maven dependency plugin nor copy sources on its own. You can use the maven dependency-plugin to extract files from jar: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack</id> <phase>prepare-package</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem>

Categories : Java

how to find list of files file name starts with All_Responses_11367*.txt and copy total files to another directory in unix command
This find command should give all file starting with All_Responses_11367* in current directory modified/created in last 77 days: find . -name "All_Responses_11367*" -maxdepth 1 -type f -mtime -77 -exec cp '{}' dest ; Change dest to some other directory where you want to copy these files.

Categories : Unix

Efficiently hashing all the files of a directory (1000 2MB files)
Increasing your Java heap space could solve it short term. Long term, you want to look into reading images into a fixed-size queue that can fit in the memory. Don't read them all in at once. Enqueue the most recent image and dequeue the earliest image.

Categories : Java

Java - Get metadata of files in a directory with million files in it
Many filesystems are not efficient at handling directories with that many entries in them. There's very little you can do, codewise, to fix that. You need to try to move those files into multiple directories, to get better speed. Other possible reasons for slowness are that you're either using a data structure that takes O(n) for each entry (resulting in O(n²) total runtime), or you're running out of heap space (so that GC dominates runtime).

Categories : Java

dump files from bash script in different directory from where python script ran it
You should change directory within the same command: cmd = "/path/to/executable/executable" outputdir = "/path/to/output/" subprocess.call("cd {} && {}".format(outputdir, cmd), shell=True)

Categories : Python

Is there a way to convert some XML files in the directory to AVRO FILES?
Yes, it seems. You should have a look at this article. You can also check this github repository. Hope this help.

Categories : Xml

Can I have pre-installed files, and downloaded files in the same directory?
First Method: Move pre installed images to your private directory on first run of application, later when user purchase image it will get download to same private directory. Second Method: Create and maintain a xml it will have path for all images and update it (write new image path) when user purchase a new image. Note that it will be complex as you have to parse xml, but will help in handle path of images.

Categories : Android

Can't get new files when adding files to a directory
This is typically a problem if you've compiled a JAR. Netbeans will look in the bin folder for a pre-compiled object unless you tell it otherwise. I would just stick with Clean + Run.

Categories : Java

Counting files in if loop
By using a counter, of course. :-) $ctr = 0 foreach($tiff in $tiffs2) { if($tiff.FullName.Substring($tiff.FullName.length-12,4) -eq $pattern) { $ctr++ $tiff = $tiff.Name.split('.')[0] cd C:UsersxxxxxxxDesktopNconvertXnView #./nconvert -help > nchelp.txt . convert.exe -out pdf -c 3 -multi -n 1 $pages 1 -o "$output$tiff.pdf" "$InputLocation*.tif" } }

Categories : Powershell

Why is this not including all files?
It looks akay. Did you check if the code in the loop is iterated over twice? It could be that the first file that's included sets the value of $num to 0. If that happens, then the loop will continue, but the code including the modules is no longer executed. Anyway, this check isn't necessary. If the query doesn't return rows, then the loop condition should evaluate to false the first time already, so the if doesn't add any value. Another problem could be that the file name name doesn't match. Maybe there's a typo, or the case doesn't match (Linux file names are case sensitive!). Try to use require instead of include. It will fail if a module cannot be found, so it gives you better information if that's the case.

Categories : PHP

Counting entries in multiple CSV files
Where is mRNA defined? Maybe you should re-read the csv module examples and try to start from the beginning, try and output the data from the CSV file before trying to count the keywords.

Categories : Python

Counting fully downloaded files
A pure PHP solution could look like this (simplified): <?php $file = $_GET['file']; check_if_file_is_ok_for_download($file); header('Content-Type: ...'); header('Content-Length: ...'); header('Content-Dispostion: ...'); // more headers if necesarry ... // output the file readfile($file); // count the finished download database_add_finished_download($file); Then use download links like: http://yourserver.com/download.php?file=... Which can be url-rewritten to something like: http://yourserver.com/download/...

Categories : PHP

Where can I find large amount of exe files?
If you know any programming language you can write a simple program to pause for a random period, say 1-5 seconds, then just duplicate the EXE file 100 times and give them different names. Edit: Based on needing already made EXE files, there are a number of them in the Windows/System32 directory, it would be a really interesting experiment to run every EXE file in the Windows directory and see what happens to the stability of your computer (I think most of them are protected so they wouldn't be able to do any damage if called from the command line).

Categories : Windows



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.