Bash script: Copies image files from source dir to destination dir and adds an extra suffix on files with same file name
By : BeauFlow
Date : March 29 2020, 07:55 AM
wish helps you I have this script that copies image files from source directory to destination directory. There are some image files in the source directory that have the same name but different file size. This script also compares the two files with the same name using a stat command. Now, I want to add a string suffix e.g. IMG0897.DUP.JPG before the file extension to the files with the same file name that are going to be copied over to the destination folder. At the moment, my script adds the file size of the file to the file name. , I modified your scripte slightly. code :
#!/bin/sh
SEARCH="IMG_*.JPG"
SOURCE=$1
DEST=$2
SUFFIX=DUP
test $# -ne 2 && echo Usage : phar image_path archive_path
if [ ! -e $1 ]
then echo Source folder does not exist
fi
if [ ! -e $2 ]
then mkdir $2/
fi
# Execute the script.
if [ "${SEARCH%% *}" = "$SEARCH" ]; then
command="find \"$1\" -name \"$SEARCH\""
else
command="find \"$1\" -name \"${SEARCH%% *}\""$(for i in ${SEARCH#* }; do echo -n " -o -name \"$i\""; done)
fi
# Run the main loop.
eval "$command" | while read file; do
bn=$(basename "$file")
bc=$(stat -c%s "$file")
if [ -f "${2}/$bn" ] && [ "$bc" -ne $(stat -c%s "${2}/$bn") ]; then
bc=$(echo ${bn}|cut -d. -f2)
bn=$(echo ${bn}|cut -d. -f1)
bn=$bn.$SUFFIX.$bc**
fi
if [ -f "${2}/$bn" ]; then
echo "File ${2}/$bn already exists."
else
echo "Copying $file to $2/$bn"
cp -a "$file" "$2/$bn"
fi
done
exit 0
else
echo "Error : Can't find $1 or $2"
exit 1
fi
|
Spring Validation adds suffix to my message code
By : Dmitry Beletsky
Date : March 29 2020, 07:55 AM
wish helps you I'm trying to implement form validation with Spring Validator, following these tutorials from dzone and mkyong. It seems the Validator method validate is called upon form submission, errors are thrown, but the message codes aren't the same that I specified. , add this to your configuration xml : code :
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
p:basename="classpath:messages" />
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
|
Entity Framework adds extra field in database. and adds both members of composite key
By : Yasmin Landa
Date : March 29 2020, 07:55 AM
I wish did fix the issue. you must use fluent API for set relations and add ColumnAttribute to order keys : code :
[Table("Artikel")]
public class Artikel
{
[Key]
[Column(Order = 1)]
public string Artnr { get; set; }
[Key]
[Column(Order = 2)]
public string ArtVersie { get; set; }
public string ArtOmschrijving { get; set; }
public Dossier Dossier { get; set; }
public string Dossiernummer { get; set; }
}
[Table("Dossier")]
public class Dossier
{
[Key]
[Column(Order = 1)]
public string Dossiernummer { get; set; }
[Key]
[Column(Order = 2)]
public string Dossierversie { get; set; }
[Required]
public string Dossierreferentie { get; set; }
[Required]
public string Relatienr { get; set; }
public ICollection<Artikel> Artikels { get; set; }
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
builder.Entity<Dossier>()
.HasMany(x => x.Artikels)
.WithOne(a => a.Dossier)
.HasForeignKey(a => new { a.Dossiernummer, a.Artnr });
builder.Entity<Artikel>()
.HasKey(x => new {x.Artnr,x.ArtVersie});
builder.Entity<Dossier>()
.HasKey(x => new {x.Dossiernummer,x.Dossierversie});
}
|
How to connect SSL on Hana DB - SAP [SQL Error 4321 - only secure connections are allowed]
By : user3361235
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further following the link SAP - Go (golang) Support a made the code below: , after a lot of tests I found this palliative solution: code :
package main
import (
"crypto/tls"
"database/sql"
"github.com/SAP/go-hdb/driver"
_ "github.com/SAP/go-hdb/driver"
"log"
)
const (
HOST = "host"
PORT = ":port"
USERNAME = "user"
PASSWORD = "password"
)
func main() {
c := driver.NewBasicAuthConnector(
HOST+PORT,
USERNAME,
PASSWORD)
tlsConfig := tls.Config{
InsecureSkipVerify: false,
ServerName: HOST,
}
c.SetTLSConfig(&tlsConfig)
db := sql.OpenDB(c)
var id int
var name string
res := db.QueryRow("SELECT * FROM SCHEMA.TABLE LIMIT 1")
res.Scan(&id, &name)
log.Println("res ", id, name)
}
|
FSDataOutputStream.writeUTF() adds extra characters at the start of the data on hdfs. How to avoid this extra data?
By : s m shawon
Date : March 29 2020, 07:55 AM
|