w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Batch Command to Move Files from Sub Directories to New Directory
Try using For /F "TOKENS=1 DELIMS=%_TabSpace%" %%B In ('dir %1 /a-d /S /B /OD') DO ( the /s will cause recursion. The downside is that the output of the dir command is then d:pathfile.ext - which may not marry well with your "TOKENS=1 DELIMS=%_TabSpace%". You'd probably need to use "delims=" (ie, no delimiters, hence entire line in token1). You can then retrieve the various parts of the full-filename as %%~dB, %%~pB, %%~nB and %%~xB (the drive, path, naem and extension - and you can combine these parts if you wish by using %%~nxB for name+extension, for instance. Supplemental info - batch commented. @ECHO OFF SETLOCAL :: The above two lines are a traditional batch introduction. :: The first turns `ECHO`ing of the command to the console OFF :: The second makes all changes to the en

Categories : Windows

Linking boost::filesystem on Ubuntu 13.04
Just a suggestion: 1)Check that your boost library contains required symbols, you can use something like this: nm -D /usr/lib64/libboost_filesystem.so.1.52.0 | grep detail | c++filt | grep your names 2)Try to change order of linking library, for example put -lboost_bla-bla-bla to the end of command line, and run this command with g++ again, not use make or something, just copy paste command and make experiments with it.

Categories : C++

How do I enumerate through a directory in Objective-C, and essentially clear out all the directories of non-directory files?
Something like this will work: NSURL *rootURL = ... // File URL of the root directory you need NSFileManager *fm = [NSFileManager defaultManager]; NSDirectoryEnumerator *dirEnumerator = [fm enumeratorAtURL:rootURL includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] options:NSDirectoryEnumerationSkipsHiddenFiles errorHandler:nil]; for (NSURL *url in dirEnumerator) { NSNumber *isDirectory; [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL]; if (![isDirectory boolValue]) { // This is a file - remove it [fm removeItemAtURL:url error:NULL]; } }

Categories : Objective C

Copy files from source directory to target directory and exclude specific file types from specified directories
This is one way to do it $SourceDirectory = 'C:Source' $DestinationDirectory = 'C:Destination' $ExcludeExtentions = '*.txt*', '*.xml*' $ExcludeSubDirectory = 'C:Sourcead_directory1', 'C:Sourcead_directory2' Get-ChildItem $SourceDirectory -Recurse -Exclude $ExcludeExtentions | Where-Object { $ExcludeSubDirectory -notcontains $_.DirectoryName } | Copy-Item -Destination $DestinationDirectory Your best friend here is Where-Object, or where. It takes a scriptblock as parameter and uses that scriptblock to validate each object that goes through pipeline. Only objects that make script return $true are passed through Where-Object. Also, take a look at the object that represents a file you get from Get-ChildItem. It has Name, Directory and DirectoryName containing pieces of file's FullNam

Categories : File

Flyway command line filesystem migrations from actual command line input
flyway.cmd -configFile=/path/to/other/configFile.conf should do what you want. I just checked and it seems I forgot to document this on the website (It is in the usage description of the tool itself). Could you file an issue against the website, requesting this to be added?

Categories : Windows

Allow Maven to automatically create directories in Ubuntu
No, you don't need to create the folder by hand or with an ant script. If the target folder doesn't exist when you run mvn, it will create it So my guess is that you have a permissions issue The user running maven can't create folders in /home/andrew/flume-sources just as a test, run mvn as root sudo mvn package if that works then it is what I said and you will need to 1) chown the folder so that the user running maven can create folders in it (rw) or 2) run mvn from the same user that owns the folder (which i'm guessing is andrew)

Categories : Maven

Where is my data (directories) store by slapd (OpenLDAP) on ubuntu?
You're using the new 'online conf option' (olc). Also as a backend you're loading the Berkeley database (bdb). Can you please paste the output of the following command (which will list your current configuration, requires root/sudo): ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn Where is my data? Your data should be at the specified location /var/lib/ldap. how to check/list my backend? You can try the following, which should list all users under your local domain: ldapsearch -x -LLL -H ldap:/// -b dc=home,dc=local dn You should have at least 1 entry from this query - the db manager: olcRootDN: cn=admin,dc=home,dc=local olcRootPW: admin In general: Make sure your ldap server is up and running: ps ax | grep ldap Your output should be something similar to:

Categories : Ubuntu

hadoop jar command points to local filesystem
hadoop jar only runs jar files that you can access locally1. Just for the sake of curiosity - here is the relevant source that looks for the jar in the hadoop jar command. public static void main(String[] args) throws Throwable { String usage = "RunJar jarFile [mainClass] args..."; if (args.length < 1) { System.err.println(usage); System.exit(-1); } int firstArg = 0; String fileName = args[firstArg++]; File file = new File(fileName); if (!file.exists() || !file.isFile()) { System.err.println("Not a valid JAR: " + file.getCanonicalPath()); System.exit(-1); } ... } 1 This is true for every Hadoop version I've come accross. Your results may vary.

Categories : Hadoop

Fetching Directory Count And Reporting It Back
In your code, you have: int count = dir.GetFiles().Length; //THE SPEECH PROGRAM TO REPLY BACK HOW MANY FILES IN THE FOLDER JARVIS.Speak("You have" + dir.Length; + "files in your downloads folder"); You have the directory count from your call to dir.GetFiles().Length assigned to the count variable. Therefore, your last line can be: JARVIS.Speak("You have " + count + " files in your downloads folder"); dir.Length is incorrect, because dir is a DirectoryInfo object, which has no Length property.

Categories : C#

1 to 2 mb XML file in MSSQL or Filesystem / Size based storing criteria for XML files
2 Mb shouldn't be a problem. I think the max limit for binary is 2 GB. Not sure, can check references on MSDN. Filestream or BLOB storage is also one option if you are dealing in huge files. The guide which you are requesting is not the solution because there will be many differing school of thoughts there. A guide just based on size may not be. A few pointers here for your reference. Bit old, but relevant: http://blog.sqlauthority.com/2009/07/13/sql-server-blob-pointer-to-image-image-in-database-filestream-storage/ SQL Server Express database size / BLOB storage

Categories : Asp Net

Facebook OG:image tags reporting wrong size
I did a Facebook share on http://www.diveboard.com/dennis.arreborg/D5wJDrE and it correctly used image http://st5.diveboard.com/222/22562_8e364ce284eaa3ecb3f8ab5c84789310_large.jpeg. So no image size problem there. I encountered situations with my own website in which images were not given as options to include in the share, although they met the size requirments: picture must be at least 50px by 50px (though minimum 200px by 200px is preferred) and have a maximum aspect ratio of 3:1. Just trying to share again solved the problem, and I read somewhere in the Facebook docs that you need to give Facebook 24 hours to somehow update itself for new images on your site. I would love to give you references to the corresponding Facebook docs, but can't find it back, because they are being change

Categories : Facebook

Get all directories within directory nodejs
This should do it: fs = require 'fs' getDirs = (rootDir) -> files = fs.readdirSync(rootDir) dirs = [] for file in files if file[0] != '.' filePath = "#{rootDir}/#{file}" stat = fs.statSync(filePath) if stat.isDirectory() dirs.push(file) return dirs async version: fs = require 'fs' getDirs = (rootDir, cb) -> fs.readdir rootDir, (err, files) -> dirs = [] for file, index in files if file[0] != '.' filePath = "#{rootDir}/#{file}" fs.stat filePath, (err, stat) -> if stat.isDirectory() dirs.push(file) if files.length == (index + 1) cb(dirs) js vers

Categories : Node Js

While creating the directory I'm getting some sub directories instead?
Specify the format of the string representation of your date time: DateTime.Now.ToString("dd-MM-yy"); See MSDN - Custom Date and Time Format Strings for more info!

Categories : C#

.htaccess redirect all sub directories under sub directory
Give this a try: <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^windows/([^/]+)/?$ /windows/ct.php?ct=$1 [L] </IfModule> For your localhost use this one: <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase /Site/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^windows/([^/]+)/?$ windows/ct.php?ct=$1 [NC,L] </IfModule>

Categories : Htaccess

counting number of directories in a specific directory
find is also printing the directory itself: $ find .vim/ -maxdepth 1 -type d .vim/ .vim/indent .vim/colors .vim/doc .vim/after .vim/autoload .vim/compiler .vim/plugin .vim/syntax .vim/ftplugin .vim/bundle .vim/ftdetect You can instead test the directory's children and do not descend into them at all: $ find .vim/* -maxdepth 0 -type d .vim/after .vim/autoload .vim/bundle .vim/colors .vim/compiler .vim/doc .vim/ftdetect .vim/ftplugin .vim/indent .vim/plugin .vim/syntax $ find .vim/* -maxdepth 0 -type d | wc -l 11 $ find .vim/ -maxdepth 1 -type d | wc -l 12 You can also use ls: $ ls -l .vim | grep -c ^d 11 $ ls -l .vim total 52 drwxrwxr-x 3 anossovp anossovp 4096 Aug 29 2012 after drwxrwxr-x 2 anossovp anossovp 4096 Aug 29 2012 autoload drwxrwxr-x 13 anossovp anossovp 4096 Aug 2

Categories : Linux

Linux zip a directory excluding some internal directories
It's not an error, it's a warning. Archives containing absolute paths to files are a security risk. Imagine an archive containing /etc/passwd. If you insist upon having the absolute paths in the archive, use the -P option: -P, --absolute-names don't strip leading `/'s from file names

Categories : Linux

Rename the pdf file inside sub-directories to the name of the sub directory
@ECHO OFF &SETLOCAL for /F "delims=" %%a in ('dir /b /s /a-d *.pdf') do ( set "fname=%%~fa" for %%b in ("%%~dpa.") do set "nname=%%~nxb" setlocal enabledelayedexpansion ECHO ren "!fname!" "!nname!.pdf" endlocal ) Note: you can rename only one pdf/folder. Some other code for the OP: @ECHO OFF &SETLOCAL MKDIR "H:Myfolder est" for /f "delims=" %%i in ('DIR /b /a-d "H:Myfolder"') do ( ECHO %%i CD "H:Myfolder\%%~i" ren *.pdf "%%~nxi.pdf" copy *.pdf "H:Myfolder est" cd H:Myfolder ) cd H:Myfolder est del H:Myfolder est est.pdf

Categories : Batch File

How can I list files and directories with them directory levels
I think you can use file path as key and level number as value using dictionary. and parse the file path string to calculate level number, use string.split string[] words = s.Split('\');

Categories : C#

Execute command in different directories
Just tested this, seems to work. Run 'mvn clean' in the directory of any pom containing 1.8.6: find . -name 'pom.xml' -print0 | xargs -0 grep -l '1.8.6' | xargs -I XX find . -path XX -execdir mvn clean ;

Categories : Maven

Grep command- How to use in different directories
I'm not sure to understand what you want. Can't you just run grep -rwn word /some/dir1/ /other/dir2/ Read the GNU grep documentation!

Categories : Linux

find directories having size greater than x MB
If I'm interpreting your question right, I think this might be what you want: cd /home du -sm * | awk '$1 > 1000' This will show all directories in /home that contain more than 1000MB. If your version of du doesn't support -m, you can use du -sk and adjust the awk bit to look for more than 1,000,000KB instead...

Categories : Linux

How to output CSS files to single directory from several input directories?
Consider creating a sass directory with dummy files for each of your components: project/ css/ foo.css bar.css baz.css modules/ foo/ foo.scss bar/ bar.scss baz/ baz.scss sass/ foo.scss bar.scss baz.scss Each dummy file should import the corresponding component. sass/foo.scss: @import "../modules/foo/foo.scss"; When you have all dummy files set up, run sass --update sass:css from the root of your project.

Categories : CSS

NSFileManager list directory contents excluding directories
You can go a little deeper with a directory enumerator. How about this? NSDirectoryEnumerator *dirEnumerator = [localFileManager enumeratorAtURL:directoryToScan includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey, NSURLIsDirectoryKey,nil] options:NSDirectoryEnumerationSkipsSubdirectoryDescendants errorHandler:nil]; NSMutableArray *theArray=[NSMutableArray array]; for (NSURL *theURL in dirEnumerator) { // Retrieve the file name. From NSURLNameKey, cached during the enumeration. NSString *fileName; [theURL getResourceValue:&fileName forKey:NSURLNameKey error:NULL]; // Retrieve whether a directory. From NSURLIsDirectoryKey, also // cached during the enumeration. NSNumber *isDirectory; [theURL getResourceValue:&isDirectory forKey:NSURL

Categories : Objective C

Copy a single file to all sub directories under a certain directory using Ant Script
The following example uses the groovy ANT task. Example ├── build.xml ├── lib │   └── groovy-all-2.1.6.jar ├── src │   └── index.html └── target └── DirectoryA ├── index.html ├── SubdirectoryAA │   └── index.html └── SubdirectoryAB ├── index.html └── SubdirectoryABA └── index.html build.xml <project name="demo" default="copy"> <path id="build.path"> <pathelement location="lib/groovy-all-2.1.6.jar"/> </path> <target name="copy"> <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/> <dirset id="trgDirs" dir="ta

Categories : PHP

I'm trying to compress some files from one directory to another but I'm getting access denied on one of the directories why?
It doesn't work because you pass a directory name for the second parameter to CompressDirectory. You should pass a file name like.... string output = Path.Combine(zippedFileDirectory, "MyZipFile.7z"); ..... compressor.CompressDirectory(source, output);

Categories : C#

Replace multiple files in sub directories with file from a different directory
try this: cd /d "C:Users----DocumentsTrainRuns" FOR /D /R %%a IN (*) do if exist "%%~a est1.hfl" echo copy /y "test1.hfl" "%%~a" Look at the output and remove the word echo if it looks good. Accepting an answer - how does it work?

Categories : Windows

python walk directory tree with excluding certain directories
root gives the entire path and not just the root from where you started. The docs makes it a bit more clear to what it's doing: for dirpath, dirnames, filenames in os.walk('/usr/lib'): print dirpath See the docs here

Categories : Python

Command line loop through directories
You might try this: @echo off pushd "%~1" for /D %%i in (*) do ( pushd "%%~i" for /f "skip=3 delims=" %%F in ( 'dir /a-d /o-d /b') do ECHO del /f "%%~F" popd ) popd

Categories : Batch File

Non recursive makefile for manu sources directories with flat .obj directory
Simply include a makefile that create explicit dependencies: # Makefile OBJ_DIR:=objects SRC_FILES := $(notdir $(SRCS)) all: $(SRC_FILES:%.c=$(OBJ_DIR)/%.o) tmp_srcs := $(SRCS) include $(foreach dummy, $(SRCS), object_rule.mk) $(OBJ_DIR)/.sentinel: mkdir -p $(dir $@) && touch $@ The trick is in the combination of the include statement and a foreach. The foreach will generate as many "object_rule.mk" as there are files listed in SRCS. The included makefile, object_rule.mk simply generates the object rule for the corresponding source file like this: ifeq (,$(tmp_srcs)) $(error this makefile requires the variable tmp_srcs to be set) endif src_path:=$(word 1, $(tmp_srcs)) ifeq (1, $(words $(tmp_srcs))) tmp_srcs:= else tmp_srcs:=$(wordlist 2, $(words $(tmp_srcs)), $(tmp_src

Categories : C

Running a script in nested directories without repercussions in the executing directory
in your first script change: ./gdp $file; to ./gdp $file $dirname; in your second script change: ' $1 > summary_$1; sort -k2n summary_$1 | uniq > holder; cat temp > useragents_$1; cat holder >> useragents_$1; more useragents_$1; to ' $1 > $2/summary_$1; sort -k2n $2/summary_$1 | uniq > $2/holder; cat temp > $2/useragents_$1; cat $2/holder >> $2/useragents_$1; more $2/useragents_$1;

Categories : Linux

searching for values stored in an arraylist through all the files within a directory and its sub directories
List all the files in a directory. `public void listFilesAndFilesSubDirectories(String directoryName){ File directory = new File(directoryName); //get all the files from a directory File[] fList = directory.listFiles(); for (File file : fList){ if (file.isFile()){ System.out.println(file.getAbsolutePath()); } else if (file.isDirectory()){ listFilesAndFilesSubDirectories(file.getAbsolutePath()); } } }` Now loop through your list of files reading each one. Now iterate the list containing the words, check with each word. If you find the word, add the file name in another list. See to that you iterate the file in the outer loop and the word inside the file loop.

Categories : Java

PHP FILES Recursive backup of directories, deleting main directory
As shown from your function-output, the directories are not empty. I suppose that the data is of low value and just needs to be backed up. I assume you are running Linux from your choice of a slash rather than a backslash. Naturally directories incur links or inodes, with metadata, which in linux can be checked via df -hi The Inode-Ids of files can be shown via the -i flag of ls ls -i filename ls -iltr ls -ltri `echo $HOME` Inodes take up space, and introduce overhead in file-system operations. So much to the motivation to remove the directories. PHP's rmdir function to remove directories requires that The directory must be empty, and the relevant permissions must permit this. It is also non-recursive. Approach 1: flatten filenames and move the files to a backup directory, t

Categories : PHP

Command works in command line but gives 'no such file or directory' in bash script
Remove the quotes around line 8. Like this: ./optAlg.exe "$inputFile" 500 2>&1 > "output/$outputFile" By placing quotes around the whole line you tell bash to execute a command which is called exactly ./optAlg.exe $inputFile 500 2>&1 > output/$outputFile and of course there is no such command. In reality you want to run ./optAlg.exe with parameters. Do not forget to place quotes around the variables because otherwise filenames that have whitespace characters are going to be passed as several arguments. Please read about arguments. And you can read about common pitfalls as well.

Categories : Bash

How to open Command Prompt, change directory and execute a command using Java code (Windows)
If you just want to run an application with a specific working directory, the easiest way is to use a ProcessBuilder: ProcessBuilder pb = new ProcessBuilder(executable, arguments, if, any); pb.directory(theWorkingDirectory); pb.start();

Categories : Java

How to affect 2 in directories column for a file ( ls command)
I tried to creat a symbolic link but its still 1 You need a hardlink instead (i.e. ln without -s). That number is the count of references to the inode and a symbolic link doesn't increase it.

Categories : Unix

Fetch all files,size,path from directories and subdirectories php
Use glob $folder = dirname( __FILE__ ) ."./images/*"; foreach( glob( './images/*.*' ) as $filename ) { echo $filename; echo $size = filesize($filename); }

Categories : PHP

Shell script cannot be executed from some directories even though its directory is added to the "PATH" variable
You should add the complete path to your bin directory, not just bin. If bin is in your $HOME, you can add $HOME/bin or ~/bin.

Categories : Linux

Executing a command from the current directory without dot slash like "./command"
What you can do is add the current dir (.) to the $PATH: export PATH=.:$PATH But this can pose a security issue, so be aware of that. See this ServerFault answer on why it's not so good idea, especially for the root account.

Categories : Bash

order of files unix find on two directories with or command
The find command will search the directories in the order given. Since you said find /tmp/dir1 /tmp/dir2 ..... it will always first find evrything that matches below /tmp/dir1, then /tmp/dir2. Yet, subdirectories and files can, of course, appear in any order.

Categories : Linux

How to skip Virtual Directories in Web Deploy Command line?
I think you can use the -skip parameters (although, I have never applied them to Virtul Directories as I usually sync specific web apps, not entire web servers). E.g. -skip:objectname='filePath',absolutepath='logs\.*\someNameToExclude.txt' See the manual on TechNet: -skip:skipAction=<action>,objectName=<objectName>,keyAttribute=<key>,absolutePath=<absolutePath>,attributes.<attributeName>=<attributeValue>,xPath=<xpathExpression> Special Shortcuts -skip:ApplicationPool=<applicationPoolName> -skip:Directory=<directoryPath> -skip:File=<filePath> -skip:WebApplication=<webApplicationName> -skip:WebSite=<webSitelName>

Categories : Iis



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